Skip to content

Commit

Permalink
Use react-native-crypto to support react native environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanvosberg committed Feb 12, 2020
1 parent 31d827d commit 61762a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"load-grunt-config": "^0.16.0",
"lodash": "^4.17.11"
},
"optionalDependencies": {
"react-native-crypto": "^2.2.0"
},
"keywords": [
"security",
"crypto",
Expand Down
7 changes: 7 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
} catch (err) {}
}

// React native crypto import via require (React Native)
if (!crypto && typeof require === 'function') {
try {
crypto = require('react-native-crypto');
} catch (err) {}
}

/*
* Cryptographically secure pseudorandom number generator
*
Expand Down

0 comments on commit 61762a9

Please sign in to comment.