示例#1
0
        public dataOperations.hashes hashFileStream(forkStream fs)
        {
            MD5  md5sum  = new MD5CryptoServiceProvider();
            SHA1 sha1sum = new SHA1CryptoServiceProvider();

            byte[] md5result;
            byte[] sha1result;

            dataOperations.hashes result = new dataOperations.hashes();

            md5result = md5sum.ComputeHash(fs);

            StringBuilder sbmd5 = new StringBuilder();

            for (int i = 0; i < md5result.Length; i++)
            {
                sbmd5.Append(md5result[i].ToString("X2"));
            }

            result.md5sum = sbmd5.ToString();

            sha1result = sha1sum.ComputeHash(fs);

            StringBuilder sbsha1 = new StringBuilder();

            for (int i = 0; i < md5result.Length; i++)
            {
                sbsha1.Append(md5result[i].ToString("X2"));
            }

            result.sha1sum = sbsha1.ToString();

            fs.Close();

            return(result);
        }
示例#2
0
        public dataOperations.hashes hashFileStream(forkStream fs)
        {
            MD5 md5sum = new MD5CryptoServiceProvider();
            SHA1 sha1sum = new SHA1CryptoServiceProvider();

            byte[] md5result;
            byte[] sha1result;

            dataOperations.hashes result = new dataOperations.hashes();

            md5result = md5sum.ComputeHash(fs);

            StringBuilder sbmd5 = new StringBuilder();

            for (int i = 0; i < md5result.Length; i++)
            {
                sbmd5.Append(md5result[i].ToString("X2"));
            }

            result.md5sum = sbmd5.ToString();

            sha1result = sha1sum.ComputeHash(fs);

            StringBuilder sbsha1 = new StringBuilder();

            for (int i = 0; i < md5result.Length; i++)
            {
                sbsha1.Append(md5result[i].ToString("X2"));
            }

            result.sha1sum = sbsha1.ToString();

            fs.Close();

            return result;
        }