File tree 1 file changed +2
-5
lines changed
1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change 14
14
15
15
import { Chacha20 } from 'ts-chacha20' ;
16
16
import { Utils } from '../lib/utils' ;
17
+ import * as crypto from 'crypto' ;
17
18
18
19
export type PRNGSeed = `${'sodium' | 'gen5' | number } ,${string } `;
19
20
export type SodiumRNGSeed = [ 'sodium' , string ] ;
@@ -212,11 +213,7 @@ export class SodiumRNG implements RNG {
212
213
static generateSeed ( ) : SodiumRNGSeed {
213
214
return [
214
215
'sodium' ,
215
- // 32 bits each, 128 bits total (16 bytes)
216
- Math . trunc ( Math . random ( ) * 2 ** 32 ) . toString ( 16 ) . padStart ( 8 , '0' ) +
217
- Math . trunc ( Math . random ( ) * 2 ** 32 ) . toString ( 16 ) . padStart ( 8 , '0' ) +
218
- Math . trunc ( Math . random ( ) * 2 ** 32 ) . toString ( 16 ) . padStart ( 8 , '0' ) +
219
- Math . trunc ( Math . random ( ) * 2 ** 32 ) . toString ( 16 ) . padStart ( 8 , '0' ) ,
216
+ crypto . randomBytes ( 16 ) . toString ( 'hex' ) ,
220
217
] ;
221
218
}
222
219
}
You can’t perform that action at this time.
0 commit comments