Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Return a MD5 hexa encoded string (See related posts)

public static string MD5_ComputeHexaHash (string text) {
	// Gets the MD5 hash for text
	MD5 md5 = new MD5CryptoServiceProvider();
	byte[] data = Encoding.Default.GetBytes(text);
	byte[] hash = md5.ComputeHash(data);
	// Transforms as hexa
	string hexaHash = "";
	foreach (byte b in hash) {
		hexaHash += String.Format("{0:x2}", b);
	}
	// Returns MD5 hexa hash
	return hexaHash;
}

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts