SenseNet.ContentRepository.Tools.CalculateMD5 C# (CSharp) Method

CalculateMD5() public static method

public static CalculateMD5 ( Stream stream, int bufferSize ) : string
stream Stream
bufferSize int
return string
        public static string CalculateMD5(Stream stream, int bufferSize)
        {
            MD5 md5Hasher = MD5.Create();

            byte[] buffer = new byte[bufferSize];
            int readBytes;

            while ((readBytes = stream.Read(buffer, 0, bufferSize)) > 0)
            {
                md5Hasher.TransformBlock(buffer, 0, readBytes, buffer, 0);
            }

            md5Hasher.TransformFinalBlock(new byte[0], 0, 0);

            var result = md5Hasher.Hash.Aggregate(string.Empty, (full, next) => full + next.ToString("x2"));
            return result;
        }

Same methods

Tools::CalculateMD5 ( string s ) : string