New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

6bithash

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

6bithash

**Hash function package** for hashing id's ( in positive integer ) to an alphanumeric short string using a 6 bit map ( User can also prvide thier own Custom 6 bit map )

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
0
Created
Source

6bithash

Hash function package for hashing id's ( in positive integer ) to an alphanumeric short string using a 6 bit map ( User can also prvide thier own Custom 6 bit map )

I built this to solve the problem of getting short hash for numbers ( i was making a link shortner )

This is Made Using TypeScript and Node.js

How to use

Install with npm

npm install 6bithash

Install with pnpm

pnpm add 6bithash

Then, you can import the hash function as :

import { generateHash } from '6bithash';

or

const { generateHash } = require('6bithash');

Providing a custom hash function

The custom hash function must have key as 6bit integers and value as you want as a string.

Example:

import { generateHash } from '6bithash';
myMap = {
    "000000" : "u",
    ...
    ...
    "111111" : "o",
}
const Number = 1001;
const result = generateHash(Number,{myMap});

Note

  • The minimum number of characters in a string hash depends on the how big the number is.
  • Pass a larger number as a Argument to get a hash with more characters.
  • If you are using TypeScript the result type is string.

Example:

Javascript :

const result = generateHash(959492);
console.log(result); // result = dQqe

TypeScript :

const result:string = generateHash(959492);
console.log(result); // result = dQqe

File Structure

6bithash
├── dist
│ └── index.d.mts
│ └── index.d.ts
│ └── index.js
│ └── index.mjs
├── src
│ └── customMap.ts
│ └── index.ts
│ └── types.ts
├── tests
│ └── index.test.ts
├── .gitignore
├── License
├── pnpm-lock.yaml
├── package.json
├── jest.config.json
├── Readme.md
└── tsconfig.json
└── tsup.config.json

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

bit Mapping

FAQs

Package last updated on 20 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts