예제 #1
0
        public static bool IsMd5Valid(string messageBody, string expectedMd5)
        {
            if (messageBody == null)
            {
                throw new ArgumentNullException("messageBody");
            }

            // Define the hash algorithm to use
            byte[] hashBytes;
            using (var hash = new MD5Cng())
            {
                hashBytes = hash.ComputeHash(Encoding.UTF8.GetBytes(messageBody));
                hash.Clear();
            }

            var messageBodyMd5 = hashBytes.ToHex();

            if (messageBodyMd5 == expectedMd5)
            {
                return(true);
            }

            return(false);
        }