Example #1
0
        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)));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
 public void ToHash(string str, string result)
 {
     Assert.Equal(str.ToHash <MD5>(), ByteUtility.FromHex(result));
     Assert.Equal(str.ToHash <MD5>(), ByteUtility.FromHex(result));
 }