The Node.js Crypto module bolsters cryptography. It gives cryptographic usefulness that incorporates a lot of wrappers for open SSL's hash HMAC, figure, unravel, sign and confirm functions.
What is Hash
A hash is a fixed-length series of bits for example procedurally and deterministically created from some subjective square of source data.
What is HMAC
HMAC represents Hash-based Message Authentication Code. It is a procedure for applying a hash calculation to the two information and a mystery key that outcomes in a solitary last hash.
Encryption Example utilizing Hash and HMAC
Open Node.js order brief and run the accompanying code:
Encryption example using Cipher
Open Node.js command prompt and run the following code:
Decryption model utilizing Decipher
- const crypto = require('crypto');
- const decipher = crypto.createDecipher('aes192', 'a password');
- var encrypted = '4ce3b761d58398aed30d5af898a0656a3174d9c7d7502e781e83cf6b9fb836d5';
- var decrypted = decipher.update(encrypted, 'hex', 'utf8');
- decrypted += decipher.final('utf8');