Chapter 2: Dealing with Binary and Random Data
When building solutions that leverage cryptography, we're almost always faced with two issues.
The first is managing binary data, which is a sequence of bytes, including characters that can't be represented as text. Most people have the experience of opening a binary file (such as an image and an executable application) in a text editor such as Notepad and being presented with a sequence of random, garbled symbols that can't be read, let alone edited.
In cryptography, encrypted messages, hashes, keys, and sometimes even decrypted messages are guaranteed to contain non-printable, binary data. This introduces challenges for developers as binary data often requires special handling to be visualized (such as while debugging our applications), stored, and transferred.
In this chapter, we'll explore how we can use encodings such as base64 and hex (short for hexadecimal) with Node.js to make binary data representable...