Encryption-Decryption module is present in the Boiler Plate. We have used the crypto library in order to implement the encryption decryption functionality.
The objective of Encryption-Decryption module
To start the encryption-decryption service we need to set the APPLY_ENCRYPTION variable to 1 in the .env file.
APPLY_ENCRYPTION=
We can also set these constants according to our preference in the crypto.ts file.
const inputEncoding=
const outputEncoding=
const salt=
const algorithm=
const password=
Since we require to encrypt the request and responses of the application, Encryption-Decryption service is being included in the core module.
A key, in the context of symmetric cryptography, is something you keep secret. Anyone who knows your key (or can guess it) can decrypt any data you've encrypted with it (or forge any authentication codes you've calculated with it, etc.).
An IV or initialization vector is, in its broadest sense, just the initial value used to start some iterated process. The term is used in a couple of different contexts and implies different security requirements in each of them.
A nonce, in the broad sense, is just "a number used only once". The only thing generally demanded of a nonce is that it should never be used twice (within the relevant scope, such as encryption with a particular key). The unique IVs used for block cipher encryption qualify as nonces, but various other cryptographic schemes make use of nonces as well.
Encryption operation mode and the padding scheme should be chosen appropriately to guarantee data confidentiality, integrity and authenticity:
Noncompliant Code Example
crypto.createCipheriv("AES-128-CBC", key, iv);
crypto.createCipheriv("AES-128-ECB", key, "");
Compliant Solution
crypto.createCipheriv("AES-256-GCM", key, iv);
https://www.devglan.com/online-tools/aes-encryption-decryption