V0.7.1 Arroyo Toad
Added a method to transform a string to a public key
This commit is contained in:
parent
15bae1af19
commit
b95f20a474
@ -33,12 +33,19 @@ export async function pem2_P256key(filePath: string) {
|
||||
const publicKeyBytes = await Deno.readFile(filePath);
|
||||
const pemKey = new TextDecoder().decode(publicKeyBytes);
|
||||
|
||||
return pemString2_P256key(pemKey)
|
||||
}
|
||||
|
||||
|
||||
export async function pemString2_P256key(pemString: string) {
|
||||
|
||||
|
||||
// fetch the part of the PEM string between header and footer
|
||||
const pemHeader = "-----BEGIN PUBLIC KEY-----";
|
||||
const pemFooter = "-----END PUBLIC KEY-----";
|
||||
const pemContents = pemKey.substring(
|
||||
const pemContents = pemString.substring(
|
||||
pemHeader.length,
|
||||
pemKey.length - pemFooter.length - 1,
|
||||
pemString.length - pemFooter.length - 1,
|
||||
);
|
||||
// base64 decode the string to get the binary data
|
||||
// convert from a binary string to an ArrayBuffer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user