File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
examples/wallet/app/utils Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,9 @@ import aesjs from 'aes-js';
3
3
import blakejs from 'blakejs' ;
4
4
5
5
const blake2b = data => blakejs . blake2b ( data , null , 32 ) ;
6
- const SECRET = 'wallet_demo#' ;
7
- const AES_SECRET = ':aes_secret#' ;
8
6
9
7
export function aesEncrypt ( unlockWalletPassword : string , text : string ) : string {
10
- const aesPasswordText = unlockWalletPassword
11
- . concat ( SECRET )
12
- . concat ( AES_SECRET ) ;
13
- const aesKey = blake2b ( aesPasswordText ) ;
8
+ const aesKey = blake2b ( unlockWalletPassword ) ;
14
9
const aesCtr = new aesjs . ModeOfOperation . ctr ( aesKey , new aesjs . Counter ( 5 ) ) ;
15
10
const encryptedBytes = aesCtr . encrypt ( aesjs . utils . utf8 . toBytes ( text ) ) ;
16
11
const encryptedHex = aesjs . utils . hex . fromBytes ( encryptedBytes ) ;
@@ -21,10 +16,7 @@ export function aesDecrypt(
21
16
unlockWalletPassword : string ,
22
17
encryptedHex : string
23
18
) : string {
24
- const aesPasswordText = unlockWalletPassword
25
- . concat ( SECRET )
26
- . concat ( AES_SECRET ) ;
27
- const aesKey = blake2b ( aesPasswordText ) ;
19
+ const aesKey = blake2b ( unlockWalletPassword ) ;
28
20
const aesCtr = new aesjs . ModeOfOperation . ctr ( aesKey , new aesjs . Counter ( 5 ) ) ;
29
21
const decryptedBytes = aesCtr . decrypt ( aesjs . utils . hex . toBytes ( encryptedHex ) ) ;
30
22
const decryptedText = aesjs . utils . utf8 . fromBytes ( decryptedBytes ) ;
You can’t perform that action at this time.
0 commit comments