Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Aug 4, 2023
1 parent e2295bc commit 508aa98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ If you don't like NPM, a standalone

```js
// import * from '@noble/ciphers'; // Error: use sub-imports, to ensure small app size

// Simple chacha: xchacha20poly1305 with prepended-to-ciphertext random nonce:
// nonce || ciphertext || mac
import { encrypt, decrypt, utf8ToBytes, randomKey } from '@noble/ciphers/simple';
// import { encrypt, decrypt } from 'npm:@noble/[email protected]/simple'; // Deno

// Simple chacha API: xchacha20poly1305 with random nonce.
// Nonce is prepended to ciphertext: (nonce || ciphertext || mac)
const key = randomKey();
const plaintext = utf8ToBytes('hello'); // Library works over Uint8Array-s
const ciphertext = encrypt(key, plaintext);
const plaintext_ = decrypt(key, ciphertext); // == plaintext

// Simple AES API: aes_256_gcm with random nonce.
// Nonce is auto-prepended to ciphertext: (nonce || ciphertext || mac)
// Simple AES: AES-256-GCM with prepended-to-ciphertext random nonce:
// nonce || ciphertext || mac
import { aes_encrypt, aes_decrypt } from '@noble/ciphers/simple';
const a_key = randomKey();
const a_ciphertext = await aes_encrypt(a_key, plaintext);
Expand Down

0 comments on commit 508aa98

Please sign in to comment.