Git Product home page Git Product logo

murmurhash-net's People

Contributors

darrenkopp avatar jwaimann avatar scovetta avatar sharpseeer 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  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  avatar  avatar  avatar  avatar  avatar  avatar

murmurhash-net's Issues

X86 algorithm does not generate same outputs as X64 algorithm

With the same seed, the two algorithms do not generate the same hashes given the same input. Is this expected?

// Example
var murmur86 = MurmurHash.Create128(0, true, AlgorithmPreference.X86);
var murmur64 = MurmurHash.Create128(0, true, AlgorithmPreference.X64);
byte[] data = Guid.NewGuid().ToByteArray();

// Assert fails
Assert.Equal(murmur86.ComputeHash(data), murmur64.ComputeHash(data));

I ran into this on accident because the default argument, AlgorithmPreference.Auto picks based on bitness of the application. I was generating hashes from two different applications against the same data store. One of those applications happened to be 32bit and the other 64.

Set licence type on nuget package

Is your feature request related to a problem? Please describe.

In dependency track this package is reporting as not having a licence type specified

Describe the solution you'd like

The PackageLicenseExpression property is set in the csproj so thay the NUGET package has the information. This can then be included in the SBOM so that analysis can occur in the appropriate tools

Describe alternatives you've considered

Ignore them, bundle licence file into package & reference the file.

Additional context

N/a

same bytes different hash

i initialize MurMurHash with a fixed seed (131).
Different assemblies calling ComputeHash with a given array of bytes produce different hashes .
I double checked and i swear i'm sober :)

How is that possible?

Does Murmur32 instance is thread safe?

Hello.

I just saw the usage of this library in Seq's tutorial: https://blog.datalust.co/serilog-tutorial/ (check for Event type enrichment).

When I created the enrichment listed there I notice the Murmur32 class is a IDisposable and Seq's example does't dispose it.

Should I create this instance every time I need to hash something and then dispose it or I should have a global static instance?

Thanks.

.Net Core Support

Currently this library cannot be used in .Net Core apps. It would be great if this library can target .Net Standard.

TransformBlock() behaves incorrectly when input data length is not a multiple of 16

When the length of the input data is not a multiple of 16, TransformBlock() does not behave correctly. In the following example, the same hash is generated for different byte sequences:

using System.Security.Cryptography;
using System.Text;
using Murmur;

{
    using HashAlgorithm hashAlgorithm = MurmurHash.Create128(preference: AlgorithmPreference.X64);
    TransformSingleByte(hashAlgorithm, 1);
    TransformSingleByte(hashAlgorithm, 1);
    TransformSingleByte(hashAlgorithm, 1);
    TransformSingleByte(hashAlgorithm, 1);
    hashAlgorithm.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
    PrintBytes(hashAlgorithm.Hash!);
}

{
    using HashAlgorithm hashAlgorithm = MurmurHash.Create128(preference: AlgorithmPreference.X64);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 0);
    hashAlgorithm.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
    PrintBytes(hashAlgorithm.Hash!);
}

{
    using HashAlgorithm hashAlgorithm = MurmurHash.Create128(preference: AlgorithmPreference.X64);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 1);
    TransformSingleByte(hashAlgorithm, 1);
    hashAlgorithm.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
    PrintBytes(hashAlgorithm.Hash!);
}

{
    using HashAlgorithm hashAlgorithm = MurmurHash.Create128(preference: AlgorithmPreference.X64);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 1);
    TransformSingleByte(hashAlgorithm, 0);
    TransformSingleByte(hashAlgorithm, 1);
    hashAlgorithm.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
    PrintBytes(hashAlgorithm.Hash!);
}

static void TransformSingleByte(
    HashAlgorithm hashAlgorithm,
    byte @byte) =>
    hashAlgorithm.TransformBlock(new[] {@byte}, 0, 1, null, 0);

static void PrintBytes(IEnumerable<byte> bytes)
{
    var stringBuilder = new StringBuilder();
    foreach (var @byte in bytes)
    {
        stringBuilder.AppendFormat("{0:X2}", @byte);
    }
    Console.WriteLine(stringBuilder.ToString());
}

Output:

BC764CD8DDF7A0CFF126F51C16239658
BC764CD8DDF7A0CFF126F51C16239658
BC764CD8DDF7A0CFF126F51C16239658
BC764CD8DDF7A0CFF126F51C16239658

Improve package readme

Summary

I wish for the nuget packages to have a more informative readme.

Details

The nuget package should be using the same readme as the repo to make it as easy as possible for a user to get started with the package.

Benchmarks required

Does it make sense to add some benchmarks? That would be great to compare performance with another implementations.

Error on TryComputeHash

The generic HashAlgorithm.TryComputeHash(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten) implementation of this function gives an error on the FinalBlock call.

It would be nice to overload this method

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.