Skip to content

Commit f2d24c9

Browse files
save file
1 parent 0a86871 commit f2d24c9

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

  • blog/26-04-26/x509-certificates-in-js---encrypt-decrypt-data/ex

blog/26-04-26/x509-certificates-in-js---encrypt-decrypt-data/ex/x509-nodejs.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,32 +80,15 @@
8080
}//blob_b64
8181

8282

83-
84-
85-
86-
async function blob_b64(blob){
87-
88-
var buf = await blob.arrayBuffer();
89-
var bytes = new Uint8Array(buf);
90-
var bin = bytes.reduce((acc,byte)=>acc+=String.fromCharCode(byte),'');
91-
var b64 = btoa(bin);
92-
return b64;
93-
94-
}//blob_b64
95-
96-
9783
function b64_blob(b64){
9884

99-
var bin = atob(b64);
100-
var bytes = [...bin].map(c=>c.charCodeAt(0));
101-
var buf = new Uint8Array(bytes);
85+
var buf = Buffer.from(b64,'base64');
10286
var blob = new Blob([buf]);
10387
return blob;
10488

10589
}//b64_blob
10690

10791

108-
10992
//:
11093

11194

0 commit comments

Comments
 (0)