public void ToHexAndFromHex() { Random rand = new Random((int)DateTime.Now.Ticks); var testData = new byte[1024]; rand.NextBytes(testData); Assert.Equal(testData, ByteUtility.FromHex(ByteUtility.ToHex(testData))); }
public void ToHash() { var path = Guid.NewGuid().ToString() + ".txt"; using (var stream = File.CreateText(path)) { stream.Write("1234"); } Assert.Equal(ByteUtility.FromHex("81dc9bdb52d04dc20036dbd8313ed055"), new FileInfo(path).ToHash <MD5>()); System.IO.File.Delete(path); }
public void ToHash() { var path = Guid.NewGuid().ToString() + ".txt"; using (var stream = System.IO.File.CreateText(path)) { stream.Write("1234"); } using (var file = System.IO.File.Open(path, System.IO.FileMode.Open)) { Assert.Equal(ByteUtility.FromHex("81dc9bdb52d04dc20036dbd8313ed055"), file.ToHash <MD5>()); } System.IO.File.Delete(path); }
public void ToHash(string str, string result) { Assert.Equal(str.ToHash <MD5>(), ByteUtility.FromHex(result)); Assert.Equal(str.ToHash <MD5>(), ByteUtility.FromHex(result)); }