Add tests for passphrase
This commit is contained in:
parent
dea8d778ee
commit
fbf021cd09
3 changed files with 22 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var CryptoJS = CryptoJS || require('crypto-js');
|
||||||
|
|
||||||
function Passphrase(config) {
|
function Passphrase(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
this.salt = config.salt || 'mjuBtGybi/4=';
|
this.salt = config.salt || 'mjuBtGybi/4=';
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@
|
||||||
"mock-fs": "^2.3.1",
|
"mock-fs": "^2.3.1",
|
||||||
"node-cryptojs-aes": "0.4.0",
|
"node-cryptojs-aes": "0.4.0",
|
||||||
"travis-cov": "0.2.5",
|
"travis-cov": "0.2.5",
|
||||||
"uglifyify": "1.2.3"
|
"uglifyify": "1.2.3",
|
||||||
|
"crypto-js": "3.1.2"
|
||||||
},
|
},
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"homepage": "https://github.com/bitpay/copay",
|
"homepage": "https://github.com/bitpay/copay",
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ try {
|
||||||
}
|
}
|
||||||
var Passphrase = copay.Passphrase;
|
var Passphrase = copay.Passphrase;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('Passphrase model', function() {
|
describe('Passphrase model', function() {
|
||||||
|
|
||||||
it('should create an instance', function() {
|
it('should create an instance', function() {
|
||||||
|
|
@ -20,4 +18,22 @@ describe('Passphrase model', function() {
|
||||||
should.exist(p);
|
should.exist(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should generate key from password', function () {
|
||||||
|
var p = new Passphrase({
|
||||||
|
salt: 'mjuBtGybi/4=',
|
||||||
|
iterations: 10,
|
||||||
|
});
|
||||||
|
var pass = '123456';
|
||||||
|
var k = p.get(pass);
|
||||||
|
var k64 = p.getBase64(pass);
|
||||||
|
|
||||||
|
// Note: hashes were generated using CryptoJS
|
||||||
|
k.toString().should.equal('2283fe11b9a189b82f1c09200806920cbdd8ef752f53dea910f90ab526f441acdbd5128555647a7e390a1a9fea042226963ccd0f7851030b3d6e282ccebaa17e');
|
||||||
|
k64.toString().should.equal('IoP+EbmhibgvHAkgCAaSDL3Y73UvU96pEPkKtSb0Qazb1RKFVWR6fjkKGp/qBCImljzND3hRAws9bigszrqhfg==');
|
||||||
|
|
||||||
|
p.getBase64Async(pass, function (ret) {
|
||||||
|
ret.toString().should.equal('IoP+EbmhibgvHAkgCAaSDL3Y73UvU96pEPkKtSb0Qazb1RKFVWR6fjkKGp/qBCImljzND3hRAws9bigszrqhfg==');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue