I am new to node js I am unable to encrypt and decrypt whole object at once but this code working fine for simple plain text string.
const generateLicense = async () => {
var plaindata = {
Client_Host_Name: 'localhost',
Client_IP: '123123',
Generation_Date: "2022-02-11",
Expiration_Date: "2022-10-01",
User_Agent: "this is user agent",
Software_Version: "s201g120",
}
var hasheddata = SHA256(plaindata).toString()
console.log("hashed data", hasheddata)
var key = "password@111"
// Encrypte the data
var encrypted = crypto.AES.encrypt(plaindata, key).toString();
// Printing the encrypted data
console.log("encrypted data",encrypted)
// Decrypting the data
var decrypted = crypto.AES.decrypt(encrypted, key)
.toString(crypto.enc.Utf8)
console.log("decrypted data",decrypted)
}
generateLicense();
return