Giter VIP home page Giter VIP logo

quickhash's Introduction

quickhash

Fast non-cryptographically secure file hash approximation

This provides an approximate hash for large files by reading N bytes for every X bytes of a file. Typically it hashes 4KB for every 2MB of a file. To cover the end of files it also hashes the last 4KB of the file.

For very large files, this is much faster than creating a hash for the entire file, and under certain assumptions, just as useful.

The main assumption is that your use case has no need for cryptographically secure hashes as it would be easy to craft collisions with intent.

The main use is to create a 'relatively' unique hash for a file that can help in identifying 'duplicate' files where you're not worried about bad actors. For example, you may receive largeish (1GB+) video clips that you need to hash quickly for a responsive app to determine if you've already seen that file or not before. This code will create an approximate MD5 hash about 40x to 60x faster than a full MD5 hash. By varying the amount of N bytes hashed and X bytes skipped, you can adjust to your use case.

I've made PHP and Perl versions, but basic idea could be easily expanded.

quickhash's People

Contributors

filmo avatar

Watchers

 avatar  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.