Skip to content

Asymmetric encryption in Nodejs

How asymmetric encryption works?

In an asymmetric key encryption scheme, anyone can encrypt messages using the public key, but only the holder of the paired private key can decrypt. Security depends on the secrecy of the private key.

asymmetric key cryptography

Generate private and public key

To generate private and public key we will use openssl:

How to use the keys in nodejs e javascript

To encrypt and decrypt in nodejs we can use crypto: