Chris Veness created a really great gist that shares code to encrypt and decrypt data using the Web Crypto API here.
This gist breaks down the code in that gist step by step, detailing a real-world scenario with actual data.
It might be helpful to have that gist open in another tab and use this gist to walk through each line of code.
One interesting use case for this would be to encrypt on a client, and then decrypt in the cloud with something like a Lambda function. In order to do this, you could use Node's latest version as of this gist, version 15, which includes a webcrypto
module that's designed to be a Node implementation of the Web Crypto API. Lambdas can't use v15 by default -- however, you can create a custom Lambda layer that contains v15.