hash-numbers
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

hash-numbers

Goal is to turn incrementing numbers into harder to guess numbers. Big plus would be to be able to decode encoded result back to original number. New methods are very welcome.

This repository has npm release pipeline configuration. When new release tag is made, pipeline will automatically package and upload a new version.

Usage

const HashNumber = require("hash-numbers").default;
const hashNumber = new HashNumber({
    algorithm: 'DEFAULT',
    salt: 'Czb8ZQja',
    prefix: 'HN-',
    suffix: '',
});
console.log(hashNumber.encode(1));
console.log(hashNumber.encode(2));
console.log(hashNumber.encode(3));

Features

  • Prefix and suffix option.
  • Salted/seeded encoding result.
  • ALGORITHM option to support more future ideas.

Sample results

DEFAULT

717 / 1
1434 / 2
2151 / 3
2868 / 4
3585 / 5
4302 / 6
5019 / 7
5736 / 8
6453 / 9
  • Salt affects to the length of encoded value.

CRC32

1578314305
954565637
1340257427
779738832
1501490778
1065893916
1217360010
667914981
1355326067
  • Encode only.

SKR_KOBLITZ_ALGO

7410851152308010 / 1
7302372875975395 / 2
7299112721931640 / 3
7299117621102511 / 4
7299117543837988 / 5
7299117540150787 / 6
7299117539959456 / 7

Readme

Keywords

none

Package Sidebar

Install

npm i hash-numbers

Weekly Downloads

0

Version

0.9.0

License

MIT

Unpacked Size

61.9 kB

Total Files

39

Last publish

Collaborators

  • norkator