-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
33 lines (33 loc) · 1.18 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
const symCryptor = require( './index' );
symCryptor.rndBytes( 32 )
.then( result => {
console.log( "32 Random bytes with 'symCryptor.rndBytes( 32 )'" );
console.log( result );
console.log( '' );
return result;
} )
.then( hashKey => {
const hmac = symCryptor.getHmac( 'Hello world!', hashKey );
console.log( "KMAC256 of 'Hello world!' with 'symCryptor.getHmac( \"Hello world!\", secret )' and 32 Random bytes as secret" );
console.log( hmac );
console.log( '' );
return hashKey;
} )
.then( hashKey => {
symCryptor.rndBytes( 32 )
.then( key => {
symCryptor.encrypt( 'Hello world!', key, hashKey )
.then( encrypted => {
console.log( "Encrypted 'Hello world!' with 'symCryptor.encrypt( \"Hello world!\", key, hashKey )'" );
console.log( encrypted );
console.log( '' );
symCryptor.decrypt( encrypted, key, hashKey )
.then( decrypted => {
console.log( "Decrypted 'Hello world!' with symCryptor.decrypt( encrypted, key, hashKey )" );
console.log( decrypted.toString() );
console.log( '' );
} );
} )
} );
} );