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
To encrypt and decrypt data, simply use encrypt() and decrypt() function from an instance of crypto-js. var bytes = CryptoJS. AES. decrypt(ciphertext, 'my-secret-key@123');
CryptoJS is a growing collection of standard and secure cryptographic algorithms implemented in JavaScript using best practices and patterns. They are fast, and they have a consistent and simple interface.
It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI should look like. JSX may remind you of a template language, but it comes with the full power of JavaScript. JSX produces React “elements”.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With