securely store encryptation passwords

This commit is contained in:
Manuel Araoz 2014-04-15 19:14:42 -03:00
parent 54f42f8278
commit 929c6ffa6d
2 changed files with 6 additions and 4 deletions

View File

@ -4,18 +4,20 @@ var imports = require('soop').imports();
//var buffertools = imports.buffertools || require('buffertools'); //var buffertools = imports.buffertools || require('buffertools');
var parent = imports.parent || require('./Plain'); var parent = imports.parent || require('./Plain');
var id = 0;
function Storage() { function Storage() {
this.__uniqueid = ++id;
} }
Storage.parent = parent; Storage.parent = parent;
var passphrase = null; var pps = {};
Storage.prototype._getPassphrase = function() { Storage.prototype._getPassphrase = function() {
return passphrase; return pps[this.__uniqueid];
} }
Storage.prototype._setPassphrase = function(password) { Storage.prototype._setPassphrase = function(password) {
passphrase = password; pps[this.__uniqueid] = password;
} }
Storage.prototype._encrypt = function(data) { Storage.prototype._encrypt = function(data) {

View File

@ -16,7 +16,7 @@ if (typeof process === 'undefined' || !process.version) {
var s = new Encrypted(); var s = new Encrypted();
should.exist(s); should.exist(s);
}); });
it.skip('should fail when encrypting without a password', function() { it('should fail when encrypting without a password', function() {
var s = new Encrypted(); var s = new Encrypted();
(function(){s.set(wid, 'x', 1);}).should.throw(); (function(){s.set(wid, 'x', 1);}).should.throw();
}); });