Skip to content

Commit

Permalink
enhence cipher
Browse files Browse the repository at this point in the history
  • Loading branch information
谢宗匠 authored and notatestuser committed Sep 10, 2018
1 parent d73465c commit 77b4dfb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
1 change: 0 additions & 1 deletion __mocks__/styleMock.js

This file was deleted.

7 changes: 1 addition & 6 deletions __tests__/crypto.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import * as crypto from '../src/crypto';

const privateKey = crypto.generatePrivateKey();
let keyStore;
const keyStore = crypto.generateKeyStore(privateKey, '1234567');

describe('crypto', () => {
it('generateKeyStore baseon on privateKey', () => {
keyStore = crypto.generateKeyStore(privateKey, '1234567');
console.log(keyStore);
});

it('getPrivateKeyFromKeyStore baseon on keyStore', () => {
const seed = crypto.getPrivateKeyFromKeyStore(keyStore, '1234567');
expect(seed).toBe(privateKey);
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const generateKeyStore = (privateKey, password) => {
};

const derivedKey = cryp.pbkdf2Sync(new Buffer(password), salt, kdfparams.c, kdfparams.dklen, 'sha256');
const cipher = cryp.createCipher('aes-128-ctr', derivedKey.slice(0, 16), iv);
const cipher = cryp.createCipher('aes-256-ctr', derivedKey.slice(0, 16), iv);
if (!cipher) {
throw new Error('Unsupported cipher');
}
Expand All @@ -164,7 +164,7 @@ export const generateKeyStore = (privateKey, password) => {
cipherparams: {
iv: iv.toString('hex')
},
cipher: 'aes-128-ctr',
cipher: 'aes-256-ctr',
kdf: 'pbkdf2',
kdfparams: kdfparams,
mac: mac
Expand Down

0 comments on commit 77b4dfb

Please sign in to comment.