|
|
@@ -1,10 +1,7 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var _crypto = require('crypto'); |
|
|
|
|
|
|
|
var _crypto2 = _interopRequireDefault(_crypto); |
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
var pbkdf2 = require('pbkdf2'); |
|
|
|
var createHmac = require('create-hmac'); |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
encryptLogin: _encryptLogin, |
|
|
@@ -31,7 +28,7 @@ function _encryptLogin(login, masterPassword) { |
|
|
|
if (!login || !masterPassword) { |
|
|
|
reject('login and master password parameters could not be empty'); |
|
|
|
} |
|
|
|
_crypto2.default.pbkdf2(masterPassword, login, iterations, keylen, 'sha256', function (error, key) { |
|
|
|
pbkdf2.pbkdf2(masterPassword, login, iterations, keylen, 'sha256', function (error, key) { |
|
|
|
if (error) { |
|
|
|
reject('error in pbkdf2'); |
|
|
|
} else { |
|
|
@@ -50,7 +47,7 @@ function _renderPassword(encryptedLogin, site, passwordOptions) { |
|
|
|
|
|
|
|
function _createHmac(encryptedLogin, salt) { |
|
|
|
return new Promise(function (resolve) { |
|
|
|
resolve(_crypto2.default.createHmac('sha256', encryptedLogin).update(salt).digest('hex')); |
|
|
|
resolve(createHmac('sha256', new Buffer(encryptedLogin)).update(salt).digest('hex')); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@@ -119,6 +116,6 @@ function _getPasswordChar(charType, index) { |
|
|
|
|
|
|
|
function createFingerprint(str) { |
|
|
|
return new Promise(function (resolve) { |
|
|
|
resolve(_crypto2.default.createHmac('sha256', str).digest('hex')); |
|
|
|
resolve(createHmac('sha256', new Buffer(str)).digest('hex')); |
|
|
|
}); |
|
|
|
} |