I'm using crypto for password encryption but when I try to call the function. I'm getting the following error. Warning of crypto.createHash method You can find the following code:
import crypto from 'crypto';
export const encrypt = (text: string) => {
const algorithm = 'aes256';
const key = crypto.createHash('sha256')
.update(String(reactApp))
.digest('base64')
.substr(0, 32);
// some calculation
return encrypted;
};
I've tried to use crypto-browserify but it's showing some more errors as you can see below. crypto-browserify error
When I run the given command as it suggests, it shows me another error which says the repository doesn't exist. Moreover, it show me this error too. polyfill
I've tried to add this code in the webpack.config.ts file too.
const path = require('path');
module.exports = {
resolve: {
fallback: {
crypto: 'crypto-browserify',
},
},
};