quickstarts/cryptography/javascript/sdk
Elena Kolevska ae812a7bf7 js sdk update
Signed-off-by: Elena Kolevska <elena@kolevska.com>
2025-02-28 17:57:40 +00:00
..
crypto-quickstart js sdk update 2025-02-28 17:57:40 +00:00
.gitignore WIP: Crypto quickstart for JS 2023-06-08 12:16:23 -07:00
README.md Fixups for JS crypto 2023-06-14 09:10:58 -07:00
makefile WIP: Crypto quickstart for JS 2023-06-08 12:16:23 -07:00

README.md

Dapr cryptography (Dapr SDK)

In this quickstart, you'll create an application that encrypts, and then decrypts, data using the Dapr cryptography APIs (high-level). We will:

  • Encrypt and then decrypt a short string, reading the result in-memory, in a Buffer
  • Encrypt and then decrypt a large file, storing the encrypted and decrypted data to files using Node.js streams

Visit the documentation to learn more about the Cryptography building block in Dapr.

Note: This example uses the Dapr SDK. Using the Dapr SDK, which leverages gRPC internally, is strongly recommended when using the high-level cryptography APIs (to encrypt and decrypt messages).

This quickstart includes one application:

  • Node.js application crypto-quickstart

Run Node.js app with Dapr

  1. Navigate into the folder with the source and install dependencies:
cd ./crypto-quickstart
npm install
  1. This sample requires a private RSA key and a 256-bit symmetric (AES) key. We will generate them using OpenSSL:
mkdir -p keys
# Generate a private RSA key, 4096-bit keys
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out keys/rsa-private-key.pem
# Generate a 256-bit key for AES
openssl rand -out keys/symmetric-key-256 32
  1. Run the Node.js app with Dapr:
dapr run --app-id crypto-quickstart --resources-path ../../../components/ -- npm start