浏览代码

add createFingerprint interface

pull/342/head
Guillaume Vincent 8 年前
父节点
当前提交
fbeed733fe
共有 2 个文件被更改,包括 14 次插入0 次删除
  1. +7
    -0
      index.js
  2. +7
    -0
      tests/api.tests.js

+ 7
- 0
index.js 查看文件

@@ -3,6 +3,7 @@ import crypto from 'crypto';
module.exports = {
encryptLogin: _encryptLogin,
renderPassword: _renderPassword,
createFingerprint: createFingerprint,
_deriveEncryptedLogin,
_getPasswordTemplate,
_prettyPrint,
@@ -102,3 +103,9 @@ function _getPasswordChar(charType, index) {
const passwordChar = passwordsChars[charType];
return passwordChar[index % passwordChar.length];
}

function createFingerprint(str) {
return new Promise(resolve => {
resolve(crypto.createHmac('sha256', str).digest('hex'))
});
}

+ 7
- 0
tests/api.tests.js 查看文件

@@ -242,3 +242,10 @@ test('auto generated render password tests', t => {
});
});


test('createFingerprint', t => {
return lesspass.createFingerprint('password').then(fingerprint => {
t.is('e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e', fingerprint);
});
});


正在加载...
取消
保存