revert to setPassphrase

This commit is contained in:
Matias Alejo Garcia 2014-09-18 16:38:18 -03:00
commit 9bfc0dd193
7 changed files with 29 additions and 29 deletions

View file

@ -12,7 +12,7 @@ function Storage(opts) {
this.__uniqueid = ++id;
if (opts.password)
this.setPassword(opts.password);
this.setPassphrase(opts.password);
try {
this.storage = opts.storage || localStorage;
@ -26,7 +26,7 @@ function Storage(opts) {
}
var pps = {};
Storage.prototype._getPassword = function() {
Storage.prototype._getPassphrase = function() {
if (!pps[this.__uniqueid])
throw new Error('NOPASSPHRASE: No passphrase set');
@ -34,12 +34,12 @@ Storage.prototype._getPassword = function() {
return pps[this.__uniqueid];
}
Storage.prototype.setPassword = function(password) {
Storage.prototype.setPassphrase = function(password) {
pps[this.__uniqueid] = password;
}
Storage.prototype._encrypt = function(string) {
var encrypted = CryptoJS.AES.encrypt(string, this._getPassword());
var encrypted = CryptoJS.AES.encrypt(string, this._getPassphrase());
var encryptedBase64 = encrypted.toString();
return encryptedBase64;
};
@ -47,7 +47,7 @@ Storage.prototype._encrypt = function(string) {
Storage.prototype._decrypt = function(base64) {
var decryptedStr = null;
try {
var decrypted = CryptoJS.AES.decrypt(base64, this._getPassword());
var decrypted = CryptoJS.AES.decrypt(base64, this._getPassphrase());
if (decrypted)
decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
} catch (e) {

View file

@ -119,7 +119,7 @@ WalletFactory.prototype.fromObj = function(inObj, skipFields) {
* @return {Wallet}
*/
WalletFactory.prototype.fromEncryptedObj = function(base64, password, skipFields) {
this.storage.setPassword(password);
this.storage.setPassphrase(password);
var walletObj = this.storage.import(base64);
if (!walletObj) return false;
return this.fromObj(walletObj, skipFields);
@ -248,7 +248,7 @@ WalletFactory.prototype.create = function(opts, cb) {
});
log.debug('\t### TxProposals Initialized');
this.storage.setPassword(opts.passphrase);
this.storage.setPassphrase(opts.passphrase);
opts.storage = this.storage;
opts.network = this.networks[opts.networkName];
@ -300,7 +300,7 @@ WalletFactory.prototype._checkVersion = function(inVersion) {
WalletFactory.prototype.open = function(walletId, passphrase, cb) {
preconditions.checkArgument(cb);
var self = this;
self.storage.setPassword(passphrase);
self.storage.setPassphrase(passphrase);
self.read(walletId, null, function(err, w) {
if (err) return cb(err);