@alvin_sudarta/primehash 1.0.0 → 1.0.1

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 +71 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # PrimeHash
2
+
3
+ An original password hashing scheme integrating a Keccak-based **Sponge Structure** with an adaptive **Built-In Salting** mechanism based on prime numbers.
4
+
5
+ No server required — runs entirely in the browser or Node.js with zero dependencies!
6
+
7
+ ## Features
8
+ - **Sponge Construction**: Resilient against Length Extension Attacks.
9
+ - **Adaptive Prime Salting**: A 64-bit dynamic salt is embedded securely inside the output structure, placed deterministically using a prime number sequence.
10
+ - **Zero Dependencies**: Pure Javascript implementation.
11
+ - **ISO/IEC 10118-1:2016 Compliant**: Evaluated design for collision and pre-image resistance.
12
+
13
+ ## Quick Start
14
+
15
+ ### 1. Installation
16
+
17
+ **Using NPM (Node.js)**
18
+ ```bash
19
+ npm install @alvin_sudarta/primehash
20
+ ```
21
+
22
+ **Using CDN (Browser)**
23
+ ```html
24
+ <script src="https://cdn.jsdelivr.net/npm/@alvin_sudarta/primehash@1.0.1/primehash.min.js"></script>
25
+ ```
26
+
27
+ ### 2. API Usage
28
+
29
+ #### Hash a Password
30
+ Generates a new hash with a built-in 64-bit random salt. *You do not need to store the salt separately in your database.*
31
+ ```javascript
32
+ const PrimeHash = require('@alvin_sudarta/primehash');
33
+
34
+ // PrimeHash.hash(password, round, length)
35
+ const hash = PrimeHash.hash("mypassword", 24, 32);
36
+ console.log(hash);
37
+ // Output: a 64-character hex string (32 bytes) containing the embedded salt
38
+ ```
39
+
40
+ #### Verify a Password
41
+ Verifies the plaintext password against the stored hash by reconstructing the prime-based position map and validating the internal salt.
42
+ ```javascript
43
+ // PrimeHash.verify(password, round, storedHash)
44
+ const result = PrimeHash.verify("mypassword", 24, hash);
45
+
46
+ if (result.valid) {
47
+ console.log("Password matches!");
48
+ // Optional (Hash Rotation): Update the stored hash in your database
49
+ // console.log("New hash for rotation:", result.updateHash);
50
+ } else {
51
+ console.log("Invalid password!");
52
+ }
53
+ ```
54
+
55
+ ## Parameter Guide
56
+
57
+ ### `hash(password, round, length)`
58
+ - `password` *(string)*: The plaintext password to hash. Must not be empty.
59
+ - `round` *(number)*: Sponge permutation rounds. Higher = slower & stronger. Recommended: **24**.
60
+ - `length` *(number)*: Output length in bytes (24 - 99). The resulting hex string length is `length * 2` characters. Recommended: **32**.
61
+
62
+ ### `verify(password, round, hashedPassword)`
63
+ - Returns an object: `{ valid: boolean, updateHash: string | null }`
64
+ - `valid` *(boolean)*: `true` if the password matches the hash.
65
+ - `updateHash` *(string)*: A freshly generated hash. It is highly recommended to replace the stored hash with this new value on every successful login to mitigate credential-stuffing attacks.
66
+
67
+ ## License
68
+ MIT License.
69
+
70
+ ---
71
+ *Developed by Alvin Sudarta - Universitas Bunda Mulia (2026)*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alvin_sudarta/primehash",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "An original password hashing scheme integrating a Keccak-based sponge construction with an adaptive prime-number-based salting mechanism.",
5
5
  "main": "primehash.js",
6
6
  "browser": "primehash.min.js",