Ryan
Ryan

Reputation: 6327

Using crypto-js in React

I generated an app using create-react-app and I want to use crypto-js I am getting the following error

crypto.sha256() is not a function

Upvotes: 12

Views: 53015

Answers (1)

sudo bangbang
sudo bangbang

Reputation: 28189

You gotta install crypto-js using

npm install crypto-js

In your js files, you have to import module you wanna use

import sha256 from 'crypto-js/sha256';

Now you can use those functions

sha256(nonce + message);

You have do define message and nonce before this

Upvotes: 26

Related Questions