Git Product home page Git Product logo

nano-md5's People

Contributors

holixus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tumobi javihache

nano-md5's Issues

Math.random() is not a secure way to generate salt

I see a couple of problems with this lib:

  1. It is using Math.random() to generate salt values. Which is not a cryptographically secure method of generating randomness.
  2. For some reason it implements its own MD5.

Just a note for someone considering using this.

Incorrect hashes for some string lengths

See comparison with md5 and blueimp-md5 libraries https://runkit.com/pober/nano-md5-incorrect-hash/1.0.1 or do it by yourself:

const nanoMD5 = require("nano-md5");
const md5 = require("md5");
const blueimpMD5 = require("blueimp-md5");

function checkHashes(length) {
    const inputString = new Array(length).fill('a').join('');
    
    const outputStringNanoMD5 = nanoMD5(inputString);
    const outputStringMD5 = md5(inputString);
    const outputStringBlueimpMD5 = blueimpMD5(inputString);
    
    if (outputStringNanoMD5 !== outputStringMD5 || outputStringNanoMD5 !== outputStringBlueimpMD5) {
        console.log(`String length: ${inputString.length}, nano-md5: ${nanoMD5(inputString)}, md5: ${outputStringMD5}, blueimp-md5: ${blueimpMD5(inputString)}`);
    }
}

for (let i = 1; i < 1000; i++) {
    checkHashes(i);
}

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.