|
5 | 5 |
|
6 | 6 | <p align="center"> |
7 | 7 | Secure, Modern, and Cross-Platform <br/> |
8 | | - Cryptography Helpers for Web, Node.js <br/> |
| 8 | + Cryptography Helpers for Web, Node.js, <br/> |
9 | 9 | Deno, Bun, and Cloudflare Workers |
10 | 10 | </p> |
11 | 11 |
|
@@ -41,15 +41,21 @@ bun add cipher-kit@latest |
41 | 41 | ## Quick Start 🚀 |
42 | 42 |
|
43 | 43 | ```typescript |
44 | | -import { createSecretKey, encrypt, decrypt } from "cipher-kit/node"; // or "cipher-kit/web-api" |
| 44 | +// Node.js Quick Start |
| 45 | +import { createSecretKey, encrypt, decrypt } from "cipher-kit/node"; |
45 | 46 |
|
46 | | -const secretKey = createSecretKey("my-passphrase"); |
| 47 | +const nodeSecretKey = createSecretKey("my-passphrase"); |
| 48 | +const encrypted = encrypt("Hello World!", nodeSecretKey); |
| 49 | +const decrypted = decrypt(encrypted, nodeSecretKey); |
| 50 | +console.log(decrypted); // "Hello World!" |
47 | 51 |
|
48 | | -const encrypted = encrypt("Hello, World!", secretKey); |
49 | | -console.log(`Encrypted: ${encrypted}`); // Encrypted: <ciphertext> |
| 52 | +// Web Quick Start |
| 53 | +import { createSecretKey, encrypt, decrypt } from "cipher-kit/web-api"; |
50 | 54 |
|
51 | | -const decrypted = decrypt(encrypted, secretKey); |
52 | | -console.log(`Decrypted: ${decrypted}`); // Decrypted: Hello, World! |
| 55 | +const webSecretKey = await createSecretKey("my-passphrase"); |
| 56 | +const encrypted = await encrypt("Hello World!", webSecretKey); |
| 57 | +const decrypted = await decrypt(encrypted, webSecretKey); |
| 58 | +console.log(decrypted); // "Hello World!" |
53 | 59 | ``` |
54 | 60 |
|
55 | 61 | ## Usage 🪛 |
@@ -245,6 +251,8 @@ The `encryptObj` and `decryptObj` functions accept the same `options` parameters |
245 | 251 |
|
246 | 252 | Hashing is a one-way process that uses an algorithm to transform data of any size into a fixed-length string of characters, called a hash value or digest. It serves as a digital fingerprint for the data, enabling quick data retrieval in hash tables, password storage, and file integrity checks. Key features include its irreversibility (you can't get the original data back from the hash). |
247 | 253 |
|
| 254 | +Not suitable for storing passwords - use `hashPassword` instead. |
| 255 | + |
248 | 256 | ```typescript |
249 | 257 | // Node.js example |
250 | 258 | import { hash } from "cipher-kit/node"; |
@@ -295,7 +303,7 @@ Password hashing is a one-way process that transforms a plaintext password into |
295 | 303 |
|
296 | 304 | Password hashing is different from general-purpose hashing because it often involves additional techniques like salting and key stretching to enhance security against brute-force attacks, and it's usually slower to compute to make rainbow table attacks less feasible. |
297 | 305 |
|
298 | | -To verify a password, the same hashing process is applied to the input password, and the resulting hash is compared to the stored hash, in a time-safe manner to prevent timing attacks. |
| 306 | +To verify a password, the same hashing process is applied to the input password, and the resulting hash is compared to the stored hash, in a constant-time comparison to prevent timing attacks. |
299 | 307 |
|
300 | 308 | ```typescript |
301 | 309 | // Node.js example |
@@ -423,6 +431,6 @@ This project is licensed under the [MIT License](https://opensource.org/licenses |
423 | 431 |
|
424 | 432 | <div align="center"> |
425 | 433 | <br/> |
426 | | -<p style="font-size: 14px; font-weight:bold;">Made by <a href="https://github.com/WolfieLeader" target="_blank" rel="nofollow">WolfieLeader</a></p> |
427 | | -<p style="font-size: 12px; font-style: italic;">Thank you!</p> |
| 434 | +<div style="font-size: 14px; font-weight:bold;"> ⚒️ Crafted carefully by <a href="https://github.com/WolfieLeader" target="_blank" rel="nofollow">WolfieLeader</a></div> |
| 435 | +<div style="font-size: 12px; font-style: italic;">Thank you!</div> |
428 | 436 | </div> |
0 commit comments