Example #1
0
 public static byte[] EncodeBytes(IBencode bCode)
 {
    var ms = new MemoryStream();
    var bw = new BinaryWriter(ms, _extendedASCIIEncoding);
    bCode.Encode(bw);
    ms.Position = 0;
    return new BinaryReader(ms, _extendedASCIIEncoding).ReadBytes((int) ms.Length);
 }
Example #2
0
      public static byte[] CalculateTorrentInfoHash(IBencode bCode)
      {
         byte[] infoBytes = EncodeBytes(bCode);

         // Hash the encoded dictionary
         return new SHA1CryptoServiceProvider().ComputeHash(infoBytes);
      }