Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const crypto = require('crypto');
- // WARNING: createCipher() is deprecated
- const cipher = crypto.createCipher('aes-256-cbc', '0000');
- let plainText = 'Hello Node';
- let updateCipherText = cipher.update(plainText, 'utf8', 'base64');
- console.log(`cipher.update('${plainText}') returns `, `'${updateCipherText}'`);
- let cipherText = cipher.final('base64');
- console.log("cipher.final() returns", `'${cipherText}'`);
- const decipher = crypto.createDecipher('aes-256-cbc', '0000');
- let updateDecipherText = decipher.update(cipherText, 'base64', 'utf8');
- console.log(`decipher.update('${cipherText}) returns `, `'${updateDecipherText}'`);
- plainText = decipher.final('utf8');
- console.log(`decipher.final() returns`, `'${plainText}'`);
Add Comment
Please, Sign In to add comment