public void GlobalSetup() { var path = Path.GetDirectoryName(typeof(StringHash).GetTypeInfo().Assembly.Location); path = Path.Combine(path, "Files", "JEOPARDY_CSV.csv"); List <byte[]> list = new(); using var reader = new StreamReader(path); using var csv = new CsvReader(reader, CultureInfo.InvariantCulture); csv.Read(); csv.ReadHeader(); StringBuilder stringBuilder = new StringBuilder(); while (csv.Read()) { var str = csv.GetField <string>(6); stringBuilder.Append(" " + str); list.Add(Encoding.UTF8.GetBytes(str)); } _sentences = list.ToArray(); _longText = Encoding.UTF8.GetBytes(stringBuilder.ToString()); list.Clear(); path = Path.GetDirectoryName(typeof(StringHash).GetTypeInfo().Assembly.Location); using var streamReader = new StreamReader(new FileStream(Path.Combine(path, "Files", "words.txt"), FileMode.Open)); while (!streamReader.EndOfStream) { list.Add(Encoding.UTF8.GetBytes(streamReader.ReadLine() ?? "")); } _words = list.ToArray(); _sha1 = System.Data.HashFunction.HashAlgorithm.HashAlgorithmWrapperFactory.Instance.Create( new HashAlgorithmWrapperConfig() { InstanceFactory = SHA1.Create }); _md5 = System.Data.HashFunction.HashAlgorithm.HashAlgorithmWrapperFactory.Instance.Create( new HashAlgorithmWrapperConfig() { InstanceFactory = MD5.Create }); _sha512 = System.Data.HashFunction.HashAlgorithm.HashAlgorithmWrapperFactory.Instance.Create( new HashAlgorithmWrapperConfig() { InstanceFactory = SHA512.Create }); _blake2 = System.Data.HashFunction.Blake2.Blake2BFactory.Instance.Create(); _city = System.Data.HashFunction.CityHash.CityHashFactory.Instance.Create(); _fnv1 = System.Data.HashFunction.FNV.FNV1Factory.Instance.Create(); _fnv1A = System.Data.HashFunction.FNV.FNV1aFactory.Instance.Create(); _jenkins3 = System.Data.HashFunction.Jenkins.JenkinsLookup3Factory.Instance.Create(); _murmur3 = System.Data.HashFunction.MurmurHash.MurmurHash3Factory.Instance.Create(); _pearson = System.Data.HashFunction.Pearson.PearsonFactory.Instance.Create(); _xxHash = System.Data.HashFunction.xxHash.xxHashFactory.Instance.Create(); }
private void NetworkChatUDP_Load(object sender, EventArgs e) { string ip = GetLocalIPAddress(); this.txtYourIP.Text = ip; //ICityHashConfig cityHashConfig = new CityHashConfig(); //ICityHash cityHash = CityHashFactory.Instance.Create(cityHashConfig); ICityHash cityHash = CityHashFactory.Instance.Create(); IHashValue hashValue32 = cityHash.ComputeHash(txtRconPassword.Text, 32); // this gives us lowercase, which is what we want txtHash.Text = hashValue32.AsHexString(); }
/// <summary> /// Static method to get hash for a number /// </summary> /// <param name="n"></param> /// <returns></returns> public static string GetHash(long n) { ICityHash cityHash = CityHashFactory.Instance.Create(); var hashValue = cityHash.ComputeHash(n); return hashValue.AsHexString(); }