GitXplorerGitXplorer
j

tiny-hashes

public
118 stars
19 forks
1 issues

Commits

List of commits on branch master.
Unverified
b0ee6142d046c1c2987a0120ea9cf51c28d957dd

Save a few more bytes in sha1/256; add more tests for big vectors

jjbt committed 9 years ago
Unverified
fb1134e243f179671e5da590a2f787d964ad18d9

I am an idiot and should learn how to Markdown.

jjbt committed 10 years ago
Unverified
5e6bbc6438ba8714d06148eb7714bdfa32030378

swap some var order so we're not using stuff before it's defined

jjbt committed 10 years ago
Unverified
ed5627e6251e3e2d0e9e810184d3d2d100266cb4

Shorted H

dduzun committed 10 years ago
Unverified
86c23a2dd42a6103c5ae126384d200619c20d8ce

Travis-CI

dduzun committed 10 years ago
Unverified
d6b7736eb4501079ef912cafa3a923f9d5f31c4e

Compile @heavensrevenge's changes (yay bytes!); also add some whitespace

jjbt committed 10 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.