Understanding public-key and hybrid cryptosystems
Before we dive into the code and learn about using asymmetric and hybrid encryption schemes with Node.js, it's worth spending a few moments understanding why we need these algorithms, what kinds of real-world problems we're trying to solve, and how they work, at least conceptually.
The need for public-key cryptography
We briefly mentioned this in the first section of Chapter 4, Symmetric Encryption in Node.js, when we explained the difference between symmetric and asymmetric ciphers, and how the latter helps solve the problem of transmitting keys to another party over an insecure channel.
For example, let's imagine that Alice needs to send Bob some confidential information via email (cryptographers have a predilection for those two names when they want to describe a situation with two parties); this is a very common problem in real life and is something you may have had to deal with yourself too on occasion!
...