Web Design that taps into the haromny and vision of your dreams.

Generate MD5 Hash of String

Generate an MD5 hash of a given string

Written By on in C#

57 words, estimated reading time 1 minutes.

This short snippet will generate an MD5 hash of a given string value in C#

public string CalculateMD5Hash(string input) 
  // Calculate MD5 hash from input 
  var md5 = MD5.Create(); 
  byte[] inputBytes = Encoding.ASCII.GetBytes(input); 
  byte[] hash = md5.ComputeHash(inputBytes); 
  // Convert byte array to hex string 
  var sb = new StringBuilder(); 
  for (int i = 0; i < hash.Length; i++) 
  return sb.ToString(); 

Last updated on: Wednesday 21st June 2017



There are no comments for this post. Be the first!


Leave a Reply

Your email address will not be published.

If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me