2 parents 12d87ce + 6799290 commit bc77e38Copy full SHA for bc77e38
1 file changed
apps/web/src/lib/x3dh.ts
@@ -27,11 +27,20 @@ const ED25519_SPKI_HEADER = new Uint8Array([
27
]);
28
29
export function toBase64(bytes: Uint8Array): string {
30
- return Buffer.from(bytes).toString('base64');
+ let binary = '';
31
+ for (let i = 0; i < bytes.length; i += 1) {
32
+ binary += String.fromCharCode(bytes[i]!);
33
+ }
34
+ return btoa(binary);
35
}
36
37
export function fromBase64(b64: string): Uint8Array {
- return new Uint8Array(Buffer.from(b64, 'base64'));
38
+ const binary = atob(b64);
39
+ const out = new Uint8Array(binary.length);
40
+ for (let i = 0; i < binary.length; i += 1) {
41
+ out[i] = binary.charCodeAt(i);
42
43
+ return out;
44
45
46
export function rawEd25519PublicKeyToSpki(rawPublicKey: Uint8Array): Uint8Array {
0 commit comments