I am currently using jsencrypt
to encrypt text using a public key. This is what I have.
file.jsx
import JsEncrypt from 'jsencrypt';
const textEncrypt = 'sensitive data';
const encrypt = new JsEncrypt.JSEncrypt();
encrypt.setPublicKey(key);
const encryptedText = encrypt.encrypt(textEncrypt);
...
Is there another library that can do this? I was reading about crypto-js
but I am not sure if it does above.
import JsEncrypt from 'jsencrypt';
import Cryptico from "cryptico";
function jsencryptMethod() {
const encrypt = new JsEncrypt.JSEncrypt();
encrypt.setPublicKey('mykey');
return encrypt.encrypt('DE52**0978');
}
function crypticoMethod(){
return Cryptico.encrypt('DE52**0978', 'mykey');
}
it('should be equal', async () => {
expect(jsencryptMethod()).toEqual(crypticoMethod());
});
Error: expect(received).toEqual(expected) // deep equality
Expected: {"status": "Invalid public key"}
Received: false