GitXplorerGitXplorer
j

tiny-hashes

public
118 stars
19 forks
1 issues

Commits

List of commits on branch master.
Unverified
1e08e1bb5346825a5713a77344dd63ec374158b1

1.0.1

jjbt committed 6 years ago
Unverified
04cfef0a15408c5fda5a77d0c0626143d36db77b

Another big round of golfing. Now <1k gzipped all-in. Also add some notes

jjbt committed 6 years ago
Unverified
317ef4957c891a6a9aa44e86a340c4dea8475216

New name!

jjbt committed 6 years ago
Unverified
a69ddde4b6c675da189b1cd246cc8bace7d2b874

golf a bunch of bytes across the board; improve consistency of similar parts

jjbt committed 6 years ago
Unverified
3438f048bf339b8d7e7658853499a6f9b2ecb218

Properly handle null characters everywhere; also simplify sha256 terminator

jjbt committed 6 years ago
Unverified
a7aed05087e000b15a1eb7f0ffbb9b3219b4820e

Completely rearrange everything to be actually usable as modules

jjbt committed 6 years ago

README

The README file for this repository.

Tiny Hash Functions

Some super-tiny implementations of common hash functions (MD5, SHA-1 and SHA-256).

Installation

From npm:

npm i tiny-hashes

Usage

Preferably using ES modules:

import md5 from 'tiny-hashes/md5';
import sha1 from 'tiny-hashes/sha1';
import sha256 from 'tiny-hashes/sha256';

md5('hello, world'); // "e4d7f1b4ed2e42d15898f4b27b019da4", hopefully

sha1('hello, world'); // "b7e23ec29af22b0b4e41da31e868d57226121c84", hopefully

sha256('hello, world'); // "09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b", hopefully

Other ways of importing

The following styles should also all work, but may be less-friendly to tree-shaking:

const md5 = require('tiny-hashes/md5');
const sha1 = require('tiny-hashes/sha1');
const sha256 = require('tiny-hashes/sha256');

import { md5, sha1, sha256 } from 'tiny-hashes';

const { md5, sha1, sha256 } = require('tiny-hashes');

When should you use this?

Please don't use this if you absolutely rely on it being correct. There are more solid solutions out there.

Please also don't use this server-side in Node.js - the crypto build-in module exists for a reason.

Basically only use this if you want a super-duper-tiny hash function in the browser that you can be about 99% sure is correct and should always be self-consistent.