My project was in Angular 6 and it had following lines of code
const crypto = require('crypto-js');
const Buffer = require('buffer').Buffer;
const decrypt = new Buffer(data.result.encr, 'base64');
const privatekey = Buffer.from(data.result.pk, 'base64');
this.decrypted = crypto.privateDecrypt(privatekey, decrypt).toString('utf-8');
return this.decrypted;
Which was working fine.
Now I migrated my code to Angular 9. And I find out that crypto
has no longer support from NPM
https://www.npmjs.com/package/crypto
It says that I have to use inbuild library of crypto. But I have no idea how to use it.
I thought crypto-js
would help me. But it didn't.
If someone knows how to use crypto
in Angular 9 or how to convert upper lines for crypto-js
then it would be great.
Note: Encryption is happening on server side using crypto only as they have nodejs.
Thanks in advance.
After 3-4 days I am finally able to resolve this.
npm-install
crypto-browserify
provides same features as crypto