public void benDictionaryEncoding() { byte[] data = System.Text.Encoding.UTF8.GetBytes("d4:spaml1:a1:bee"); BEncodedDictionary dict = new BEncodedDictionary(); BEncodedList list = new BEncodedList(); list.Add(new BEncodedString("a")); list.Add(new BEncodedString("b")); dict.Add("spam", list); Assert.AreEqual(System.Text.Encoding.UTF8.GetString(data), System.Text.Encoding.UTF8.GetString(dict.Encode())); Assert.IsTrue(Toolbox.ByteMatch(data, dict.Encode())); }
public void benDictionaryEncodingBuffered() { byte[] data = Encoding.UTF8.GetBytes("d4:spaml1:a1:bee"); var dict = new BEncodedDictionary(); var list = new BEncodedList { new BEncodedString("a"), new BEncodedString("b") }; dict.Add("spam", list); byte[] result = new byte[dict.LengthInBytes()]; dict.Encode(result, 0); Assert.IsTrue(Toolbox.ByteMatch(data, result)); }
public void benDictionaryEncoding() { byte[] data = Encoding.UTF8.GetBytes("d4:spaml1:a1:bee"); var dict = new BEncodedDictionary(); var list = new BEncodedList { new BEncodedString("a"), new BEncodedString("b") }; dict.Add("spam", list); Assert.AreEqual(Encoding.UTF8.GetString(data), Encoding.UTF8.GetString(dict.Encode())); Assert.IsTrue(Toolbox.ByteMatch(data, dict.Encode())); }
public void SHA1() { Assert.IsTrue(Toolbox.ByteMatch(torrent.SHA1, sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes("this is a sha1 hash string")))); }
public void ED2K() { Assert.IsTrue(Toolbox.ByteMatch(torrent.ED2K, sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes("ed2k isn't a sha, but who cares")))); }
public bool Equals(byte[] other) { return(other == null || other.Length != InfoHash.HASH_SIZE ? false : Toolbox.ByteMatch(Hash, other)); }
public void ByteMatch_DifferentArrayLengths2() { Assert.IsFalse(Toolbox.ByteMatch(new byte[1], 0, new byte[2], 0, 2)); Assert.IsTrue(Toolbox.ByteMatch(new byte[1], 0, new byte[2], 0, 1)); }
public void ByteMatch_DifferentArrayLengths() { Assert.IsFalse(Toolbox.ByteMatch(new byte[1], new byte[2])); }