Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.createHmac is not a function in React Native #355

Open
goodfriendshanthosh opened this issue Jun 13, 2021 · 3 comments
Open

crypto.createHmac is not a function in React Native #355

goodfriendshanthosh opened this issue Jun 13, 2021 · 3 comments

Comments

@goodfriendshanthosh
Copy link

goodfriendshanthosh commented Jun 13, 2021

Package.json
"crypto-js": "3.1.9-1"

metro.config.js
inlineRequires: true

const crypto = require('crypto-js');

const secret = 'ABC';

const hash = crypto.createHmac('sha256', secret)
.update('UPDATING')
.digest('hex');

console.log(hash)

Error: crypto.createHmac is not a function in React Native

followed this, but error still exist #259

@goodfriendshanthosh
Copy link
Author

I'm stuck.. anybody there ?

@Lord-Y
Copy link

Lord-Y commented Sep 7, 2021

Same problem with version 4.1.1

@trasherdk
Copy link

I'm guessing here 😄 The README says

var CryptoJS = require("crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));

So maybe this could work

const hmac256 = require('crypto-js/hmac-sha256)
const hash = hmac256(message, password)

or

const cryptojs = require("crypto-js");
console.log(cryptojs.HmacSHA256("Message", "Key"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants