Sfoglia il codice sorgente

add createFingerprint interface

pull/342/head
Guillaume Vincent 8 anni fa
parent
commit
fbeed733fe
2 ha cambiato i file con 14 aggiunte e 0 eliminazioni
  1. +7
    -0
      index.js
  2. +7
    -0
      tests/api.tests.js

+ 7
- 0
index.js Vedi File

@@ -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 Vedi File

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


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


Caricamento…
Annulla
Salva