コード例 #1
0
ファイル: Utils.cs プロジェクト: LeXa777/PlayGround
 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);
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: LeXa777/PlayGround
      public static byte[] CalculateTorrentInfoHash(IBencode bCode)
      {
         byte[] infoBytes = EncodeBytes(bCode);

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