In am trying to encrypt each request with the help of this code:
encryptRequest(request) {
let encryptInfo = encodeURIComponent(CryptoJS.AES.encrypt(JSON.stringify(request), ‘The screat key’).toString());
return encryptInfo;
}
and calling this code while sending request in service file. Like:
public checkAccess(solutionName: string = ‘Business Card Management’) {
let encryptReq = {
solutionName
}
let req = this.encryptDecrypt.encryptRequest(encryptReq);
return this.httpClient.post(${this.envConfigService.serverHost}/${ApiEndpointsEnum.CHECK_ACCESS}
, req)
}
And then I have add decryption code in node js, in one called decryption.ts:
function decryption(req) {
var deData= CryptoJS.AES.decrypt(decodeURIComponent(req).toString(), ‘The screat key’);
let decryptedInfo = deData.toString(CryptoJS.enc.utf8);
return decryptedInfo;
}
And calling this in route like:
this.router.post(this.checkUserAccess, decryption, this.cardsController.checkUserAccess);
Getting encrypted data like this, shown in image.
enter image description here
But not getting decryption code it is coming undefined like shown in image.
enter image description here
Priyanka Raghuwanshi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.