Giter Site home page Giter Site logo

tommasobelluzzo / fasthashes Goto Github PK

View Code? Open in Web Editor NEW
61.0 6.0 10.0 949 KB

A .NET implementation of several non-cryptographic hashes.

License: MIT License

C# 99.43% Python 0.57%
hash-functions hashing-algorithms non-cryptographic-hash-functions fast-algorithms hashing-library testing-framework

fasthashes's Introduction

๐Ÿ”ง Technologies

๐Ÿ“ˆ GitHub Stats Profile Views

User Activity Most Used Languages

๐Ÿ™ Donation

If you found any of my projects useful to you, please consider making a donation to support its maintenance and development:

PayPal

fasthashes's People

Contributors

danielmarbach avatar github-actions[bot] avatar tommasobelluzzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fasthashes's Issues

s_AllowsUnalignedRead causing inconsistent hash results in .NET 4.0

NOTE: This is probably a very niche problem since I needed to compile the source myself to get it to work with an existing .NET 4.0 project.

If the source code as is is used in .NET 4.0, I've encountered in my unit tests that the produced hash value alternates between different executions. Since it alternates between two values i suspect the problem has something to do with wrong memory alignment. This happens when compiling for "Any CPU" and executing on a 64bit OS.

Always setting the s_AllowsUnalignedRead flag in the Hash class to true seemed to fix this error. Am I correct in the understanding that if the s_AllowsUnalignedRead flag is set to true you allow less optimization?

For my application this change did not affect performance in any significant way so I might just keep it at that, but I would appreciate any insight you might have on this issue.

Best,
Elias

komihash 5

Please update komihash to v5. I would also like to inquire why komihash's benchmarked speed is low in your .NET implementation? I assume it's due to the use of 64x64 to 128 bit multiplication intrinsic which may not be available in .NET. Could you recheck the implementation? It's possible to use the __umulh intrinsic instead of _umul128, which is also fast.

There was a question about streamed implementation - komihash features a streamed implementation now.
https://github.com/avaneev/komihash

FarmHash128 throws IndexOutOfRangeException when input size is exactly 16

If input length is exactly 16 bytes then FarmHash128.ComputeHash throws an IndexOutOfRangeException .

Expected Behavior

Function should work.

Current Behavior

Exception is thrown:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at FastHashes.FarmHash128.Hash1To3(UInt64& hash1, UInt64& hash2, ReadOnlySpan`1 buffer, Int32 offset, Int32 count, UInt64 seed1, UInt64 seed2)
   at FastHashes.FarmHash128.ComputeHashInternal(ReadOnlySpan`1 buffer)
   at FastHashes.Hash.ComputeHash(Byte[] buffer, Int32 offset, Int32 count)
   at FastHashes.Hash.ComputeHash(Byte[] buffer)

Steps to Reproduce

byte[] input = new byte[16];
FarmHash128 fh = new FarmHash128();
fh.ComputeHash(input);

Note

An exception is also thrown when input size is 0.

Implementation of Stream Hashing

As far as I can see all hash functions expect an in-memory buffer.
I would like to compute hashes for very large files (way beyond RAM limits) that necessitate reading smaller chunks into memory and compute the hash in steps.
Is it at present possible with FastHash?

SpookyHash Version

Hello,
am wondering if your implementation of the SpookyHash is V2 or not. Thanks so much.

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.