hashing-token
v3.8.0
Published
hashing token , decode , password , Verify password and create Id package
Downloads
25
Maintainers
Readme
hashing Package
Links
Installation
npm install hashing-token
yarn add hashing-token
pnpm add hashing-token
Features
- Token Encryption and Decryption: Easily encrypt and decrypt data with secure tokens.
- Password Hashing: Hash passwords authentication.
- Verify Hashing: Verify passwords authentication.
- Random ID Generation: Create random and secure IDs.
import package
/*js (module)*/
const Hashing = require("hashing-token") //or
const { Token , Decode , CreateID , Passwords , Verify } = require("hashing-token")
//ts or js (ES6)
import Hashing from "hashing-token" //or
import { Token , Decode , CreateID , Passwords , Verify } from "hashing-token"
Create Id
CreateID(50 /* not required number default: 20*/)//509849995099545497481015749545
Token
Token("hashing-token"/* required string|array|object*/,"SecrateKey"/* required string*/,"SecrateKey"/*not required string*/)//f903b0aeffcf60b0933533788eafac78.92f5f87136109da77a7d4bfdcb36fb55.......
Decode
Decode("f903b0aeffcf60b0933533788eafac78.92f5f87136109da77a7d4bfdcb36fb55......."/* required string*/,"SecrateKey"/* required string*/,{SecrateKey2:"",MaxAge:1000}/*not required secrete2: string MaxAge: number (1000 = 1s)*/)//hashing-token
Password
Password("hashing-token"/* required string*/,"SecrateKey"/* required string*/,30/*not required number*/)//509849995099545497481015749545
Verify
Verify("hashing-token","509849995099545497481015749545"/*hashing required string*/,"SecrateKey"/* required string*/,30/*not required string*/)//true
Verify("hashing-token","509849995099545497481015749545"/*hashing required string*/,"SecrateKey"/* required string*/,31/*not required string*/)//false
Verify("hashing","509849995099545497481015749545"/*hashing required string*/,"SecrateKey"/* required string*/,30/*not required string*/)//false
add max age in token
import { Decode, Token } from "hashing-token";
let token = Token ("hashing-token","hashing-token-secrete",{MaxAge:3000}/*3s*/);
console.log("token: ",token);
setTimeout(async()=>await console.log("decode after 2s: ",Decode(token,"hashing-token-secrete")),2000);// hashing-token
setTimeout(async()=>await console.log("decode after 5s: ",Decode(token,"hashing-token-secrete")),5000); // the token is expired