Technical requirements
All the code samples for this chapter can be found in this book's GitHub repository at https://bit.ly/crypto-ch7.
Playground
To make it easier to build and test the code samples in these last two chapters, which often include third-party modules from npm, we have set up a "playground" that runs within your browser. You can access it at https://bit.ly/crypto-playground.
In Node.js
While this chapter and the next will be referring to JavaScript code written for web browsers, the same APIs have been made available in Node.js as a compatibility layer since version 15, released in October 2020.
In Node.js, the Web Crypto APIs are available in the webcrypto
object in the crypto
module.
For example, take this snippet of JavaScript code for the browser, which we'll be covering later in this chapter:
window.crypto.getRandomValues(array)
To use it in Node.js (15+), change from window.crypto
to the webcrypto
object, which...