fix enc base64url doc test

This commit is contained in:
fyears
2021-12-31 20:55:13 +08:00
parent 1bc6ba4b01
commit dde7d9a732
3 changed files with 23 additions and 9 deletions
+8
View File
@@ -114,6 +114,14 @@ export const base64ToBase32 = (a: string) => {
return base32.stringify(Buffer.from(a, "base64"));
};
export const base64ToBase64url = (a: string, pad: boolean = false) => {
let b = a.replace(/\+/g, "-").replace(/\//g, "_");
if (!pad) {
b = b.replace(/=/g, "");
}
return b;
};
/**
* iOS Safari could decrypt string with invalid password!
* So we need an extra way to test the decrypted result.