When I use crypto in this code, it returns 'Unknown cipher.'
const secret ="1111111111111111111";
let encryptedText='test';
const decipher = crypto.createDecipheriv('aes-256-cbc', secret, secret.slice(0, 16));
decipher.setAutoPadding(true);
let decrypted = decipher.update(encryptedText.slice(16), 'base64', 'utf8');
decrypted += decipher.final('utf8');
How to fix it?
2 Replies
I'm sorry, but the code you provided seems to be using Node.js's
crypto
module, which is not available in Deno. In Deno, we use the Web Cryptography API for cryptographic operations. The documentation does not provide a direct equivalent for your code, but it does provide examples of how to use the Web Cryptography API for various cryptographic operations such as hashing, encoding, and decoding.
Here's an example of how you might encode and decode a string using the Web Cryptography API in Deno:
Please note that this is a simple example and does not include any encryption or decryption. The Web Cryptography API in Deno does support more advanced operations like encryption and decryption, but the documentation does not provide a clear example of how to use these features. 🦕hey,
aes-256-cbc
is not implemented in node:crypto. can you open an issue on github?