Package & version:
ScryptPadding v1.0.0
Description:
Pad/Unpad messages using Scrypt hashing algorithm.
How the package works?
-
Calculate the length for padding.
-
Hash the input into the right length (using Scrypt).
-
Prepend the hash to the message.
-
To unpad, create a loop for [x] rounds ([x] will get a value, according to the padding factor).
-
Hash the message, until an exact match with the padded hex hash.
-
Returns the matched message, If got a match, or return the original input.
Example 1:
import { Pad, Unpad } from "scrypt-padding";
// or: const { Pad, Unpad } = await import("scrypt-padding");
// Step 1: Pad the message with a 4 characters length factor (default is 32).
const pad = Pad( "GO!", 4 );
// Step 2: Unpad the message ( which is: "b299fGO!" ).
const msg = Unpad( pad, 4 );
// The results: "GO!"
console.log(msg);
Example 2:
import { Pad, Unpad } from "scrypt-padding";
// or: const { Pad, Unpad } = await import("scrypt-padding");
// Step 1: Pad the message with the default 32 characters length factor.
const pad = Pad( "GO!" );
// Step 2: Unpad the message ( which is: "b299f9ac20bcfc98098e42df93a0339d401f904194634bcdafff353be90c7GO!" ).
const msg = Unpad( pad );
// The results: "GO!"
console.log(msg);
Third party:
- Scrypt implementation from scrypt-js.