@quicore/hash 1.0.0 โ†’ 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +111 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,2 +1,111 @@
1
- # hash
2
- A lightweight utility for fast access to the most commonly used hashing algorithms including SHA, Blake2, and PBKDF2
1
+ # @quicore/hash
2
+
3
+ > A lightweight utility for fast access to the most commonly used hashing algorithms including SHA, Blake2, and PBKDF2.
4
+
5
+ @quicore/hash provides a simple and unified interface to widely-used cryptographic hashing functions. It wraps Node.js' native crypto module to offer convenient helpers for generating SHA, BLAKE2, SHA3, PBKDF2, and other hashes, as well as Base62-encoded compact IDs.
6
+
7
+ ---
8
+
9
+ ## โœจ Features
10
+
11
+ * ๐Ÿ”’ Fast, secure hash generation (SHA-256, SHA-512, SHA3, BLAKE2, PBKDF2)
12
+ * ๐Ÿง  Compact Base62-encoded hashes for short unique identifiers
13
+ * ๐Ÿ’ก Unified interface for all supported algorithms
14
+ * โš ๏ธ Legacy algorithm support (MD5, SHA-1, RIPEMD160) with deprecation warnings
15
+ * ๐Ÿ”‹ Zero dependencies, fully built on Node.js native crypto
16
+
17
+ ---
18
+
19
+ ## ๐Ÿ“ฆ Installation
20
+
21
+ ```bash
22
+ npm install @quicore/hash
23
+ ```
24
+
25
+ ---
26
+
27
+ ## ๐Ÿš€ Usage
28
+
29
+ ```ts
30
+ import { GenerateHash } from '@quicore/hash';
31
+
32
+ // SHA-256
33
+ const sha = GenerateHash.SHA256('hello');
34
+
35
+ // Compact ID (Base62 encoded Blake2b hash)
36
+ const id = GenerateHash.compactHash('user@example.com');
37
+
38
+ // PBKDF2
39
+ const derivedKey = GenerateHash.PBKDF2('password123', 'random-salt');
40
+
41
+ // SHA3-256
42
+ const sha3 = GenerateHash.SHA3_256('some input');
43
+ ```
44
+
45
+ ---
46
+
47
+ ## ๐Ÿ” API Reference
48
+
49
+ ### Hash Functions
50
+
51
+ | Method | Description |
52
+ | ---------------------- | ------------------------------------------------ |
53
+ | SHA256(input) | Generates a SHA-256 hex hash |
54
+ | SHA512(input) | Generates a SHA-512 hex hash |
55
+ | SHA1(input) | โš ๏ธ Deprecated. SHA-1 hash |
56
+ | MD5(input) | โš ๏ธ Deprecated. MD5 hash |
57
+ | SHA3\_256(input) | SHA3-256 hex hash |
58
+ | SHA3\_512(input) | SHA3-512 hex hash |
59
+ | RIPEMD160(input) | RIPEMD160 hex hash |
60
+ | BLAKE2s256(input) | BLAKE2s-256 hex hash |
61
+ | blake2b(input, size) | Returns a Buffer from BLAKE2b hash |
62
+ | PBKDF2(password, salt) | PBKDF2 w/ SHA-512 (100,000 iterations, 64 bytes) |
63
+
64
+ ### Utility
65
+
66
+ | Method | Description |
67
+ | ----------------------- | ----------------------------------------------- |
68
+ | compactHash(input, len) | Returns Base62-encoded BLAKE2b digest |
69
+ | toBase62(buffer, len) | Encodes Buffer to Base62 string of given length |
70
+
71
+ ---
72
+
73
+ ## ๐Ÿ“ Defaults
74
+
75
+ * Base62 alphabet: 0-9, a-z, A-Z
76
+ * Default Base62 ID length: 22 characters
77
+ * Minimum Base62 ID length: 10 characters
78
+ * BLAKE2b default digest size: 20 bytes
79
+ * PBKDF2: 100,000 iterations, SHA-512, 64-byte output
80
+
81
+ ---
82
+
83
+ ## ๐Ÿ›‘ Deprecated Algorithms
84
+
85
+ * MD5
86
+ * SHA-1
87
+
88
+ These are retained for non-security use cases (e.g., checksum comparisons) but are not recommended for cryptographic use.
89
+
90
+ ---
91
+
92
+ ## ๐Ÿ“š Use Cases
93
+
94
+ * ID and slug generation for URLs, database keys
95
+ * Password hashing with PBKDF2
96
+ * Content fingerprinting or data integrity checks
97
+ * Simple cryptographic utilities for CLI or server-side apps
98
+
99
+ ---
100
+
101
+ ## ๐Ÿงช Example: Mongo-Friendly ID
102
+
103
+ ```ts
104
+ const id = GenerateHash.compactHash('file_upload_123');
105
+ // e.g., "03xr9SDcKVUuAkcBfYzLpT"
106
+ ```
107
+
108
+ ---
109
+
110
+ ## ๐Ÿ“œ License
111
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicore/hash",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight utility for fast access to the most commonly used hashing algorithms including SHA, Blake2, and PBKDF2",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -29,4 +29,4 @@
29
29
  "engines": {
30
30
  "node": ">=18.0.0"
31
31
  }
32
- }
32
+ }