File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,20 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
37
37
}
38
38
} catch ( err ) { }
39
39
40
- // Use getRandomValues method
41
- if ( crypto && typeof crypto . getRandomValues === 'function' ) {
42
- try {
43
- return crypto . getRandomValues ( new Uint32Array ( 1 ) ) [ 0 ] ;
44
- } catch ( err ) { }
45
- }
40
+ if ( crypto ) {
41
+ // Use getRandomValues method
42
+ if ( typeof crypto . getRandomValues === 'function' ) {
43
+ try {
44
+ return crypto . getRandomValues ( new Uint32Array ( 1 ) ) [ 0 ] ;
45
+ } catch ( err ) { }
46
+ }
46
47
47
- // Use randomBytes method
48
- if ( crypto && typeof crypto . randomBytes === 'function' ) {
49
- try {
50
- return crypto . randomBytes ( 4 ) . readInt32LE ( ) ;
51
- } catch ( err ) { }
48
+ // Use randomBytes method
49
+ if ( typeof crypto . randomBytes === 'function' ) {
50
+ try {
51
+ return crypto . randomBytes ( 4 ) . readInt32LE ( ) ;
52
+ } catch ( err ) { }
53
+ }
52
54
}
53
55
54
56
throw new Error ( 'Native crypto module could not be used to get secure random number.' ) ;
You can’t perform that action at this time.
0 commit comments