2014-06-06 12:34:30 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-24 08:36:32 -07:00
|
|
|
var chai = chai || require('chai');
|
|
|
|
var should = chai.should();
|
|
|
|
var bitcore = bitcore || require('bitcore');
|
|
|
|
var buffertools = bitcore.buffertools;
|
2014-06-15 20:55:23 -07:00
|
|
|
try {
|
|
|
|
var copay = require('copay'); //browser
|
|
|
|
} catch (e) {
|
|
|
|
var copay = require('../copay'); //node
|
|
|
|
}
|
2014-06-24 08:36:32 -07:00
|
|
|
var Passphrase = copay.Passphrase;
|
2014-06-06 12:34:30 -07:00
|
|
|
|
|
|
|
describe('Passphrase model', function() {
|
|
|
|
|
2014-06-24 08:36:32 -07:00
|
|
|
it('should create an instance', function() {
|
2014-06-06 12:34:30 -07:00
|
|
|
var p = new Passphrase();
|
|
|
|
should.exist(p);
|
|
|
|
});
|
|
|
|
|
2014-08-26 09:02:02 -07:00
|
|
|
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==');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-06-06 12:34:30 -07:00
|
|
|
});
|