The aes256-async package allows developers to easily encrypt and decrypt data by making use of the AES-256 specification. It exposes syncrhonous and asynchronous functions to avoid blocking the main thread. Moreover, the secret can be of any size because
npm install aes256-asyncThe aes256-async package allows developers to easily encrypt and decrypt data by making use of the AES-256 specification. It exposes syncrhonous and asynchronous functions to avoid blocking the main thread. Moreover, the secret can be of any size because it is hashed using the Secure Hash Algorithm 2 (SHA-256).
Install the package:
``bash`
npm i -S aes256-async
Encrypt and decrypt data asynchronously:
`typescript
import { encrypt, decrypt } from 'aes256-async';
const secret = 'My.$ecreT';
await encrypt(secret, 'Hello world!')
// OrGfQ/91d7p/1BN6Q07Jly5ZK0/7pyczjk5vgw==
await decrypt(secret, 'OrGfQ/91d7p/1BN6Q07Jly5ZK0/7pyczjk5vgw==')
// 'Hello world!'
`
Encrypt and decrypt data synchronously (blocking the main thread):
`typescript
import { encryptSync, decryptSync } from 'aes256-async';
const secret = 'My.$ecreT';
encryptSync(secret, 'Hello world!')
// OrGfQ/91d7p/1BN6Q07Jly5ZK0/7pyczjk5vgw==
decryptSync(secret, 'OrGfQ/91d7p/1BN6Q07Jly5ZK0/7pyczjk5vgw==')
// 'Hello world!'
`
- TypeScript
`bashintegration tests
npm run test:integration