File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed
Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 44
55A tiny memorable password generator
66
7- - ** Fast** : 16 times faster than ` password-generator `
8- - ** Small** : 342 bytes (minified and gzipped)
7+ - ** Fast** : 600 times faster than ` password-generator `
8+ - ** Small** : 334 bytes (minified and gzipped)
99- ** Safe** : Uses [ cryptographically strong random API] ( https://nodejs.org/api/crypto.html ) instead of ` Math.random `
1010- ** No dependencies**
1111- Supports Node.js and browsers
Original file line number Diff line number Diff line change @@ -37,25 +37,25 @@ const getRandomSyllable = ({
3737 return syllable ;
3838} ;
3939
40- const getRandomChar = stack => {
41- return stack . charAt ( random ( stack . length ) ) ;
42- } ;
40+ const getRandomChar = stack => stack [ random ( stack . length ) ] ;
4341
4442const produce = ( number , callback ) => {
45- let result = "" ;
46- for ( let index = 0 ; index < number ; index ++ ) result += callback ( index ) ;
43+ for ( var index = 0 , result = "" ; index < number ; index ++ ) {
44+ result += callback ( index ) ;
45+ }
46+
4747 return result ;
4848} ;
4949
5050let buffer = [ ] ;
5151let bufferSize = 0xffff ;
52- let bufferIndex = bufferSize + 1 ;
52+ let bufferIndex = bufferSize ;
5353
5454const random = limit => {
55- if ( ++ bufferIndex > bufferSize ) {
55+ if ( bufferIndex >= bufferSize ) {
5656 buffer = getRandomValues ( bufferSize ) ;
5757 bufferIndex = 0 ;
5858 }
5959
60- return buffer [ bufferIndex ] % limit ;
60+ return buffer [ bufferIndex ++ ] % limit ;
6161} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const libraries = [
1111 name : "omgopass" ,
1212 browser : true ,
1313 node : true ,
14- size : 342 ,
14+ size : 334 ,
1515 generate : ( ) => omgopass ( )
1616 } ,
1717 {
You can’t perform that action at this time.
0 commit comments