1.0.3 • Published 3 years ago

id-hasher v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

HashId

HashId is a library that generates short, unique, non-sequential ids from numbers.

based on hashids

Getting Started

GitHub / npm

npm i id-hasher --save

import { HashId } from "id-hasher";
const hashId = new HashId({
  salt: "a17b3c3e73ad70620e87b7170f6857c7",
  minHashLength: 6,
  prefix: "PREFIX_",
  suffix: "_SUFFIX",
});

console.log(hashId.encode(10353)); // PREFIX_GJWMQ5_SUFFIX
console.log(hashId.decode("PREFIX_GJWMQ5_SUFFIX")); // 10353

Interface

export interface HashIdConfig {
  /** hash salt */
  salt: string;
  /** prefix of hashify */
  prefix?: string;
  /** suffix of hashify  */
  suffix?: string;
  /** min length of hashify, Default: 6 */
  minHashLength?: number;
  /** allow alphabet of hashify, Default: ABCDEFGHJKLMNPQRSTUVWXYZ23456789 */
  alphabet?: string;
}
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago