コード例 #1
0
        public static byte[] ComputeHash(Stream stream)
        {
            Crypto.MD5 md5 = new Crypto.MD5();
            byte[]     buf = new byte[4096];
            int        len = buf.Length;

            while (len == buf.Length)
            {
                len = stream.Read(buf, 0, buf.Length);
                if (len > 0)
                {
                    md5.BlockUpdate(buf, 0, len);
                }
            }
            return(md5.GetHash());
        }
コード例 #2
0
 public static byte[] ComputeHash(byte[] buf, int offset, int count)
 {
     byte[] hash = null;
     if (StiBaseOptions.FIPSCompliance)
     {
         Crypto.MD5 md5 = new Crypto.MD5();
         md5.BlockUpdate(buf, offset, count);
         hash = md5.GetHash();
     }
     else
     {
         MD5CryptoServiceProvider hashMD5 = new MD5CryptoServiceProvider();
         hash = hashMD5.ComputeHash(buf, offset, count);
         hashMD5.Clear();
     }
     return(hash);
 }