I install module:
npm install --save crypto
I import it to my component:
import { createHmac } from "crypto";
But I get error:
ERROR in -------------- (4,28): Canno t find module 'crypto'.
What am I doing wrong?
The node:crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
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');
A port of node's crypto module to the browser. The goal of this module is to reimplement node's crypto module, in pure javascript so that it can run in the browser. Here is the subset that is currently implemented: createHash (sha1, sha224, sha256, sha384, sha512, md5, rmd160)
I am developing with the latest versions of Angular and 'crypto-js' seems to work fine.
Install the package and the definitions:
npm install crypto-js
npm install --save @types/crypto-js
Use it:
import { SHA256, enc } from "crypto-js";
...
login() {
...
const hashedPass = SHA256(this.loginForm.value.password).toString(enc.Hex);
...
}
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