Skip to content

xoofx/smash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smash Build status NuGet

Smash is a fast and lightweight library that provides a collection of non-cryptographic hashes for .NET

// Computes the hash of the following int32
var hash = xxHash.Create64();
hash.Write(1);
hash.Write(2);
hash.Write(3);
hash.Write(4);
var value = hash.Compute();

Features

  • Provides an implementation for the following hash methods:
    • xxHash
    • TODO: If you are looking for another hash method, PR are welcome!
  • Pure .NET implementation
  • 32bits and 64bits hashes whenever they are provided by the underlying method
  • Fast computation using aggressive inlining
  • Zero allocation library, using only structs, no managed objects.
  • Allow progressive hash computation, the hash state is updated on each Write but the hash is computed once Compute is called
    • Allows incremental hashes, copy of hashes before appending new data...etc.
  • Allows to compute the hash for structured data (Write(int32), Write(short)...etc.) and not only for a byte[]
    • This is useful when computing the hash of some datas without having to serialize them to a byte[]
  • Provides a generic HashStream<THash> to update a hash while reading/writing from another stream.

Note

The API is write count and type dependent, meaning that the following are not generating the same hash, despite their in-memory representation is the same.

var hash1 = xxHash.Create64();
hash1.Write((byte)0xFF);
hash1.Write((byte)0xFF);

var hash2 = xxHash.Create64();
hash2.Write((ushort)0xFFFF);

// Note that hash1 != hash2 in this case

If you want to be binary compatible for any writes, you will have to use just once the methods Write(byte[], int, int) or Write(IntPtr, ulong), as you would do with regular hashes functions.

Binaries

Smash is available as a NuGet package: NuGet

Compatible with the following .NET framework profiles:

  • .NET3.5
  • .NET4.0+
  • UAP10.0+
  • NetStandard1.1 running on .NET4.5+ and CoreCLR runtimes

Also Smash.Signed NuGet package provides signed assemblies.

License

This software is released under the BSD-Clause 2 license.

Credits

Smash is just an implementation of existing hash methods. All the credits should go to the following libraries.

Author

Alexandre Mutel aka xoofx.

About

Smash provides a collection of non-cryptographic hashes for .NET

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages