fix #458: improved phonetic.js password generator

This commit is contained in:
antelle 2016-12-04 08:43:57 +03:00
parent f5b75dd874
commit 2416b5fb44
3 changed files with 9 additions and 19 deletions

View File

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="keeweb node_modules" type="javaScript">
<properties>
<option name="frameworkName" value="node_modules" />
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/node_modules" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/node_modules" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -71,7 +71,10 @@ var PasswordGenerator = {
},
generatePronounceable: function(opts) {
var pass = phonetic.generate({ length: opts.length });
var pass = phonetic.generate({
length: opts.length,
seed: this.generateHash(1024)
});
var result = '';
var upper = [];
var i;

View File

@ -204,10 +204,12 @@ function getNextPhonetic(phoneticSet, simpleCap, wordObj, forceSimple) {
* @returns {number}
*/
function getNumericHash(data) {
var numeric = 0;
let numeric = 0;
data += '-Phonetic';
for (var i = 0; i < data.length; i++) {
numeric += data.charCodeAt(i);
for (let i = 0, len = data.length; i < len; i++) {
let chr = data.charCodeAt(i);
numeric = ((numeric << 5) - numeric) + chr;
numeric >>>= 0;
}
return numeric;
}