matrix-hasher.js
v0.0.4
Published
Matrix-Hasher.js is a JavaScript library that implements matrix-based hashing for secure password handling.
Downloads
302
Maintainers
Readme
Matrix-Hasher.js
Matrix-Hasher.js is a JavaScript library that implements matrix-based hashing for secure password handling. The library provides an easy-to-use interface with three main functions and has no external dependencies.
Features
- Matrix-Based Hashing: Utilizes matrix operations for secure password hashing.
- TypeScript Friendly: Use type-safe code and benefit from TypeScript's powerful static type checking..
- No Dependencies: Lightweight and easy to integrate into any project.
- Simple API: Intuitive functions for hashing and comparison.
Usage
Key Matrix Generation
To use the library, you need to generate a keyMatrix
. It must be a square matrix and seeds are required for matrix creation. It's recommended to store KEY_MATRIX_SEED
and DIMENSION
environment variables to your .env file. You can include them in your project using the dotenv
package.
Install dotenv:
npm install dotenv
Defining
seed
anddimension
in.env
fileKEY_MATRIX_SEED=123456789 DIMENSION=3
keyMatrix
Generationrequire('dotenv').config(); const { MatrixHasher } = require('matrix-hasher.js'); const dimension = parseInt(process.env.DIMENSION, 10); const keyMatrix = MatrixHasher.genKeyMatrix(process.env.KEY_MATRIX_SEED, dimension); console.log(keyMatrix);
Data Hashing
require('dotenv').config();
const { MatrixHasher } = require('matrix-hasher.js');
const dimension = parseInt(process.env.DIMENSION, 10);
const hashedData = MatrixHasher.matrixHash('secret', keyMatrix, dimension);
console.log(hashedData);
Hashed Data Comparing
require('dotenv').config();
const { MatrixHasher } = require('matrix-hasher.js');
const dimension = parseInt(process.env.DIMENSION, 10);
const isMatch = MatrixHasher.compare('secret', hashedData, keyMatrix, dimension);
console.log(isMatch);