-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45592d6
commit 7ebc7cd
Showing
9 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### 0.2.0 ### | ||
* Added: Password type **internet** | ||
|
||
### 0.1.0 ### | ||
Initial Public Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Add Random Number generator based on crypto API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const _random = require('./random'); | ||
|
||
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle | ||
function shuffle(input){ | ||
|
||
for (let i=input.length-1;i>0;i--){ | ||
const j = _random.randomIntInRange(0, i); | ||
|
||
// exchange elements | ||
const t = input[j]; | ||
input[j] = input[i]; | ||
input[i] = t; | ||
} | ||
|
||
return input; | ||
} | ||
|
||
|
||
module.exports = shuffle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const _random = require('../random'); | ||
const _cc = require('../character-classes'); | ||
const _shuffle = require('../shuffle'); | ||
|
||
// alias | ||
const _ = _random.getRandomElementsByClass; | ||
|
||
function createBasicScheme(){ | ||
return '' | ||
+ _(_cc.general, 4) | ||
+ _(_cc.numbers, 2) | ||
+ _(_cc.special, 2) | ||
+ _(_cc.general, 6) | ||
+ _(_cc.numbers, 2) | ||
+ _(_cc.special, 2) | ||
+ _(_cc.numbers, 3) | ||
; | ||
} | ||
|
||
function internet(length, shuffle){ | ||
// defaults | ||
length = length || 22; | ||
shuffle = shuffle || false; | ||
|
||
// tmp | ||
let output = ''; | ||
|
||
// generate passphrase | ||
while (output.length < length){ | ||
output += createBasicScheme(); | ||
} | ||
|
||
// limit length | ||
output = output.substr(0, length); | ||
|
||
// shuffle elements ? | ||
if (shuffle){ | ||
// to array -> shuffle -> to string | ||
output = _shuffle(output.split('')).join(''); | ||
} | ||
|
||
return output; | ||
} | ||
|
||
module.exports = internet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters