public byte[] BuildXorKey(ReadOnlySpan <byte> mixData) { // Seed value was pulled from ds.exe Span <byte> key = new byte[] { 0x43, 0x94, 0x3A, 0xFA, 0x62, 0xAB, 0x1C, 0xF4, 0x1C, 0x81, 0x76, 0xF3, 0x3E, 0x9E, 0xA8, 0xD2 }; for (int i = 0; i < mixData.Length; i++) { key[i] = mixData[i]; } SMHasher.MurmurHash3_x64_128(key, 42, out ulong[] hash); Bits.TryWriteBytes(key.Slice(0), hash[0]); Bits.TryWriteBytes(key.Slice(8), hash[1]); return(key.ToArray()); }
public IndexEntry FromData(BinaryReader reader) { uint pathLength = reader.ReadUInt32(); if (pathLength > 0) { // Strings are expected to be lowercase and prefixed with "cache:" var fullPath = Encoding.UTF8.GetString(reader.ReadBytesStrict(pathLength)); FilePath = fullPath.Replace("cache:", ""); SMHasher.MurmurHash3_x64_128(Encoding.UTF8.GetBytes(FilePath + char.MinValue), 42, out ulong[] hash); PathHash = hash[0]; } GUID = new BaseGGUUID().FromData(reader); var unknown = reader.ReadBytesStrict(16); return(this); }
private byte[] BuildXorKey() { // Murmurhash3 of the first 16 bytes of the BlockEntry header as stored in the file. No type casting = very ugly in C#. Span <byte> seed = stackalloc byte[16]; Bits.TryWriteBytes(seed.Slice(0), DecompressedOffset); Bits.TryWriteBytes(seed.Slice(8), DecompressedSize); Bits.TryWriteBytes(seed.Slice(12), XorKey1); SMHasher.MurmurHash3_x64_128(seed, 42, out ulong[] hash); Bits.TryWriteBytes(seed.Slice(0), hash[0]); Bits.TryWriteBytes(seed.Slice(8), hash[1]); // XOR the seed with the data key var key = new byte[] { 0x37, 0x4A, 0x08, 0x6C, 0x95, 0x9D, 0x15, 0x7E, 0xE8, 0xF7, 0x5A, 0x3D, 0x3F, 0x7D, 0xAA, 0x18 }; for (int i = 0; i < key.Length; i++) { key[i] ^= seed[i]; } return(MD5Context.Value.ComputeHash(key)); }
private ulong GetHashForPath(string path) { SMHasher.MurmurHash3_x64_128(Encoding.UTF8.GetBytes(path + char.MinValue), 42, out ulong[] hash); return(hash[0]); }
public static ulong GetHashForPath(string path, bool stream = false) { path = EnsureExt(path, stream).Replace('\\', '/'); SMHasher.MurmurHash3_x64_128(Encoding.UTF8.GetBytes(path + char.MinValue), 42, out ulong[] hash); return(hash[0]); }