npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hash-key

v1.1.0

Published

with this package user can genarate random long or short hexadecimal number which can be used as api key,password,id and many more

Downloads

9

Readme

hash-key

hash-key is an npm package that can generate a 16-character hexadecimal string, useful for API keys, Passwords, IDs, and many more. The package offers four, main functions: generate(), hexBetween(start, end), dataCipher(data, key), and compareHash(data, hash, key).

Installation

You can install the package using npm:

npm install hash-key

Usage

Importing the Package

First, import the package into your project:

const hexGen=require('hash-key')

generate()

The generate() function generates a 16-character hexadecimal string by default. You can also pass a parameter to generate a string of a specified length.

Example

Generate 16-character string:

const apiKey=hexGen.generate()
console.log(apiKey); // Example output : '00a232d376d3e38a'

Generate a string of a specified length (e.g., 32 characters):

const apiKey=hexGen.generate(32);
console.log(apiKey); // Example output : '8e3d13e76454658eeef8cea1fa4cc7e5'

hexBetween(start, end)

The hexBetween(start, end) function generates a 16-character hexadecimal string between the given hexadecimal inputs.

Example

Generate String between two hexadecimal values:

const apiKey=hexGen.hexBetween('3', 'f')
console.log(apiKey) //Example output : 564b6ac6684b58d5 

dataCipher(data,key)

The dataCipher(data, key) function transforms data or massage into a hash string. For hashing it uses Secure Hashing Algorithm (SAH-2). As parameters, it needs to pass data and key. The key could be any string.

Example

Let's convert a string into a hash:

const hashData=hexGen.dataCipher('hello-world','ahnyritokjc');
console.log(hashData) //Example "b40440103f22529a690e4fd0a295bec16fe29610e31663a4288727e469f06de2"

compareHash(data,hash,key)

The compareHash(data, hash, key) function compares a given piece of data with a provided hash value, using a specified key. If hash belongs to the data ,function return true , otherwise it return false

Example

Let's compare a string with a hash value:

//string: 'hello-world'
//key: 'ahnyritokjc'
//hash for the string: 'b40440103f22529a690e4fd0a295bec16fe29610e31663a4288727e469f06de2'

const hash='b40440103f22529a690e4fd0a295bec16fe29610e31663a4288727e469f06de2'
const hashMatched=hexGen.compareHash('hello-world', hash,'ahnyritokjc');
console.log(hashMatched) // output: true

Use of dataCipher() and compareHash()

The dataCipher function can be used to transform passwords into hashed values, which can then be securely stored in the database. The compareHash function is utilized to compare input data with the stored hash, ensuring that the provided password is valid by verifying the match.

Contributing

If you'd like to contribute to this project, please open an issue or submit a pull request. Contributions are welcome!

Future Functionality

N.B. I will add more functionality in later versions

contact

For more questions and feedback, please reach out to [[email protected]].