Amazon.S3.Util.AmazonS3Util.GenerateChecksumForContent C# (CSharp) Method

GenerateChecksumForContent() public static method

Generates an MD5 Digest for the string-based content
public static GenerateChecksumForContent ( string content, bool fBase64Encode ) : string
content string The content for which the MD5 Digest needs /// to be computed. ///
fBase64Encode bool Whether the returned checksum should be /// base64 encoded. ///
return string
        public static string GenerateChecksumForContent(string content, bool fBase64Encode)
        {
            // Convert the input string to a byte array and compute the hash.
            byte[] hashed = CryptoUtilFactory.CryptoInstance.ComputeMD5Hash(Encoding.UTF8.GetBytes(content));

            if (fBase64Encode)
            {
                // Convert the hash to a Base64 Encoded string and return it
                return Convert.ToBase64String(hashed);
            }
            else
            {
                return BitConverter.ToString(hashed).Replace("-", String.Empty);
            }
        }