File tree Expand file tree Collapse file tree
blog/26-04-26/x509-certificates-in-js---encrypt-decrypt-data/ex Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77aes-encrypt-decrypt-nodejs.js
88
9930-04-26
10+ 16-05-26
11+
12+ rsa keys should be 4096
13+
14+
1015
1116
1217*/
@@ -15,8 +20,30 @@ aes-encrypt-decrypt-nodejs.js
1520
1621 var crypto = require ( 'crypto' ) ;
1722
18-
19-
23+ ( async ( ) => {
24+ console . clear ( ) ;
25+
26+ var blob = new Blob ( [ 'hello world' ] ) ;
27+
28+ var key = await generateAesKey ( ) ;
29+ var key_blob = await exportAesKey ( key ) ;
30+ console . log ( 'key :' , key_blob . size ) ;
31+ var encrypted = await aesEncrypt ( key , blob ) ;
32+ var b64 = await blob_b64 ( encrypted ) ;
33+ console . log ( 'encrypted :' ) ;
34+ console . log ( b64 ) ;
35+ console . log ( ) ;
36+ var key = await importAesKey ( key_blob ) ;
37+
38+ var blob = await aesDecrypt ( key , encrypted ) ;
39+
40+ var txt = await blob . text ( ) ;
41+ console . log ( 'decrypted :' ) ;
42+ console . log ( txt ) ;
43+
44+ } ) ( ) ;
45+
46+
2047 //:
2148
2249
You can’t perform that action at this time.
0 commit comments