Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple C# method to create the hash of the email address and return Gravatar image URL for a supplied email address. As per official documentation -
public static string GetGravatarImageUrl(string emailAddress)
// Create MD5 Hash of email address
var md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(emailAddress.Trim().ToLower());
byte[] hash = md5.ComputeHash(inputBytes);
// Create lower-case hex string
var sb = new System.Text.StringBuilder();
for (int i = 0; i < hash.Length; i++)
// Build URL
return string.Concat("", sb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment