25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

64 satır
2.1 KiB

  1. var v1 = require('./src/v1');
  2. var v2 = require('./src/v2');
  3. var pbkdf2 = require('./src/pbkdf2');
  4. var objectAssign = require('object-assign');
  5. module.exports = {
  6. encryptLogin: v1.encryptLogin,
  7. renderPassword: v1.renderPassword,
  8. createFingerprint: v1.createFingerprint,
  9. _deriveEncryptedLogin: v1._deriveEncryptedLogin,
  10. _getPasswordTemplate: v1._getPasswordTemplate,
  11. _prettyPrint: v1._prettyPrint,
  12. _string2charCodes: v1._string2charCodes,
  13. _getCharType: v1._getCharType,
  14. _getPasswordChar: v1._getPasswordChar,
  15. _createHmac: v1._createHmac,
  16. generatePassword: generatePassword,
  17. _calcEntropy: v2._calcEntropy,
  18. _consumeEntropy: v2._consumeEntropy,
  19. _getSetOfCharacters: v2._getSetOfCharacters,
  20. _getConfiguredRules: v2._getConfiguredRules,
  21. _insertStringPseudoRandomly: v2._insertStringPseudoRandomly,
  22. _getOneCharPerRule: v2._getOneCharPerRule,
  23. _renderPassword: v2._renderPassword,
  24. pbkdf2: pbkdf2
  25. };
  26. var defaultPasswordProfile = {
  27. version: 2,
  28. lowercase: true,
  29. numbers: true,
  30. uppercase: true,
  31. symbols: true,
  32. keylen: 32,
  33. digest: 'sha256',
  34. length: 16,
  35. index: 1,
  36. iterations: 100000
  37. };
  38. function generatePassword(site, login, masterPassword, passwordProfile) {
  39. var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile);
  40. if (_passwordProfile.version === 1) {
  41. var options = {
  42. counter: _passwordProfile.counter,
  43. length: _passwordProfile.length,
  44. lowercase: _passwordProfile.lowercase,
  45. uppercase: _passwordProfile.uppercase,
  46. numbers: _passwordProfile.numbers,
  47. symbols: _passwordProfile.symbols
  48. };
  49. return v1.encryptLogin(login, masterPassword)
  50. .then(function (encryptedLogin) {
  51. return v1.renderPassword(encryptedLogin, site, options).then(function (generatedPassword) {
  52. return generatedPassword
  53. });
  54. });
  55. }
  56. if (_passwordProfile.version === 2) {
  57. return v2.generatePassword(site, login, masterPassword, _passwordProfile);
  58. }
  59. }