Skip to content

Commit 61762a9

Browse files
committed
Use react-native-crypto to support react native environments.
1 parent 31d827d commit 61762a9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"load-grunt-config": "^0.16.0",
3535
"lodash": "^4.17.11"
3636
},
37+
"optionalDependencies": {
38+
"react-native-crypto": "^2.2.0"
39+
},
3740
"keywords": [
3841
"security",
3942
"crypto",

src/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
2929
} catch (err) {}
3030
}
3131

32+
// React native crypto import via require (React Native)
33+
if (!crypto && typeof require === 'function') {
34+
try {
35+
crypto = require('react-native-crypto');
36+
} catch (err) {}
37+
}
38+
3239
/*
3340
* Cryptographically secure pseudorandom number generator
3441
*

0 commit comments

Comments
 (0)