Runnable example programs for @ubgo/crypt. Each subdirectory has a main.ts runnable with tsx or node --import tsx.
| Example | Demonstrates |
|---|---|
encrypt-field/ |
Encrypt-at-rest pattern for a database column. |
sign-webhook/ |
Sign and verify webhooks with HMAC-SHA256. |
random-token/ |
API keys, magic-link tokens, log correlation IDs. |
seal-with-aad/ |
Bind ciphertext to a user/tenant via AAD. |
sealer/ |
Application-wide bound-key Sealer. |
migrate-cbc-to-gcm/ |
One-shot migration from legacy AES-CBC to AEAD. |
pnpm install -g tsx
tsx examples/encrypt-field/main.tsOr from the repo root with pnpm:
pnpm exec tsx examples/encrypt-field/main.ts