Giter VIP home page Giter VIP logo

honesthash.js's Introduction

HonestHash

The best hashing algorithm for speed, uniqueness and length for Javascript



Problems of conventional hashes and HonestHash solutions

problem SPEED: hashing can't be too slow (for big files) or too fast (rainbow(*) tables)
solution: HonestHash has an optional speed parameter and can be set between 4ms ~ 22000ms

problem LENGTH: hash can't be too long (shorter hash means faster and cheaper databases)
solution: HonestHash is only 40 characters long and still without any collisions

problem SALTING: can't be hashed without a salt (rainbow tables have 43(*) billion results)
solution: HonestHash has a mandatory salt and an optional number of hashing

problem UNIVERSALITY: you must be able to reuse the same library on cliend and server
solution: HonestHash has just one implementation for Node.js and client JS

problem COLLISIONS: many hashes have already known collisions (MD5, SHA0, SHA1..)
solution: HonestHash uses internally SHA3-512 and RIPEMD-160 (not known collisions)


HonestHash




How to install and use Honest Hash?

Installation on server within package.json

> npm install honesthash
> node require("./Honesthash.js")

Short usage with salt and speed options

var options = { salt : "744bdf813e57252146", speed : 15000 };
var result = require("./Honesthash.js")(options).hex("123");

console.log(result);
> e457227529744e2146bdf813e57259f256fd7cdc

Standard usage with more instances of the hash

var hashModule = require("./Honesthash.js");

var develHash = hashModule({ speed: 1, salt: "1f5a5ab970a1945c91394", logs: true });
var testHash = hashModule({ speed: 10000, salt: "159139413f5a5970a", logs: true });
var prodHash = hashModule({ speed: 10000, salt: "d73ce9fc1776ad4f", logs: false  });

console.log( develHash.hex("123"), testHash.hex("123"), prodHash.hex("123") );

Shortest usage without options

console.log( require("./Honesthash.js")().hex("string") );
> 1176e5c9188f73a5203656949848c19680ecc062




Available options

{
  (mandatory) salt: "1234567890", // your custom hash, can be any string
  (optional) loop: 1, //  can be between 1 and 1000000
  (optional) logs: false // logs everything to console (speed, hash, string)
}




How Honest Hash works?

Hashing

Honest Hash puts raw string to SHA512 with given salt. SHA3-512 is used because its the best implementation of famous SHA serie and result is unique, without any collisions and strong. Problem is that is too long. This SHA3 result is given to hashing function RIPE160 and it result is provided back.

uniqButLong = SHA3-512("your string" + salt);
shortAndUniq = RIPE160(uniqButLong + salt);

HonestHash

Speed

Speed is inspired by Niels Provos(*) and David Mazières and theirs bcrypt. Optional speed besides incorporating a salt protects against rainbow table attacks. Hashing iterates within a loop that is set by optional parameter speed. Iteration makes hashing slower, so it remains resistant to brute-force search attacks even with increasing computer power.





Backward compatibility algorithms

Honest Hash is tested not just for English characters, but also for the Cyrillic script (1), numbers (2), special characters (3), Eastern European characters (4) and many others..

1: `бвгдеёжзийклмнопрстуфхцчшщъыьэюя`
2: `1234567890`
3: `!@#$%^&*()_-+={[}]:;"'|\?/>.<,œ∑´†¥¨ˆπ¬˚∆˙ƒ∂ßåΩ≈ç√∫˜Ω`
4: `ąàáäâãåæăăâćęèéëêìíïîîłńòóöôõøśșşțţùúüûñçżźа`
5: `zxcvbnmlkjhgfdsaqwertyuiop`




Bechmark

For a full benchmark see file docs/bechmark.md, that contains results of our benchmark. We used iMac 2011 with OSX Yosimite and Node.js v10.17. Computer had installed 4GB RAM.


HonestHash HonestHash




Licence

  • Free for all projects (commercial and non-commercial)
  • MIT licenced
  • For security reasons - use please only the original repository

honesthash.js's People

Watchers

James Cloos avatar Behrooz Babazadeh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.