/// <summary> /// Generate a deterministic Guid from a queue Id. /// </summary> /// <param name="queueId"></param> /// <returns></returns> private Guid GenerateDeterministicGuid(QueueId queueId) { // provider name hash code int providerNameGuidHash = (int)JenkinsHash.ComputeHash(this.Name); // get queueId hash code uint queueIdHash = queueId.GetUniformHashCode(); byte[] queIdHashByes = BitConverter.GetBytes(queueIdHash); short s1 = BitConverter.ToInt16(queIdHashByes, 0); short s2 = BitConverter.ToInt16(queIdHashByes, 2); // build guid tailing 8 bytes from providerNameGuidHash and queIdHashByes. var tail = new List <byte>(); tail.AddRange(BitConverter.GetBytes(providerNameGuidHash)); tail.AddRange(queIdHashByes); // make guid. // - First int is provider name hash // - Two shorts from queue Id hash // - 8 byte tail from provider name hash and queue Id hash. return(new Guid(providerNameGuidHash, s1, s2, tail.ToArray())); }
/// <summary> /// <see cref="IHasher.Hash(byte[])"/>. /// </summary> public int Hash(byte[] data) { return(unchecked ((int)JenkinsHash.ComputeHash(data))); }
public uint GenerateHash(ulong Key) { return(JenkinsHash.ComputeHash(BitConverter.GetBytes(Key))); }
public uint GenerateHash(Guid Key) { return(JenkinsHash.ComputeHash(Key.ToByteArray())); }
public uint GenerateHash(string Key) { return(JenkinsHash.ComputeHash(Key)); }
public TypeKey(byte[] key) { HashCode = unchecked ((int)JenkinsHash.ComputeHash(key)); TypeName = key; }
/// <summary> /// Performs the Jenkins hash on an input byte array /// </summary> public static byte[] JenkinsHash( byte[] input ) { using ( JenkinsHash jHash = new JenkinsHash() ) { byte[] hash = jHash.ComputeHash( input ); Array.Reverse( hash ); return hash; } }
private static int GetHashCode(byte[] value) => (int)JenkinsHash.ComputeHash(value);
internal StreamId(byte[] fullKey, ushort keyIndex) : this(fullKey, keyIndex, (int)JenkinsHash.ComputeHash(fullKey)) { }
internal StreamId(Memory <byte> fullKey, ushort keyIndex) : this(fullKey, keyIndex, (int)JenkinsHash.ComputeHash(fullKey.ToArray())) { }