1.0.0 • Published 2 years ago

ascii-hash v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

ascii-hash

Fast and naive non-cryptographic hash.

Calculates the sum of each character in a string using their character (ASCII) codes. This makes it a computationally cheap way to create relatively unique IDs. Use cases could include React key generation or the creation of a few user IDs.

Installation

npm i ascii-hash
# or
yarn add ascii-hash

Usage

const { asciiHash } = require("ascii-hash");

asciiHash("hello world!") // "1149"

For better performance with consecutive calls (such as in a React render method), consider using the memoized version which caches previous results in memory.

const { asciiHashMem } = require("ascii-hash");

asciiHashMem("hello world!") // "1149"