C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Generating MD5 for a string


Posted Date: 16 May 2008    Resource Type: Code Snippets    Category: Encryption
Author: Payal JainMember Level: Gold    
Rating: Points: 10



Introduction


Following Code snippet will help u to generate MD5 hash for a string or text value

Namespaces used


namespace System.Security.Cryptography is required to be included using:

using System.Security.Cryptography;

Classes used


Md5 and MD5CryptoServiceProvider ....to create md5 hash provider

main code



//this is the full code to generate md5
Byte[] generatedBytes,originalBytes;
MD5 md5 = new MD5CryptoServiceProvider();

//convert string data to array of bytes
originalBytes = ASCIIEncoding.Default.GetBytes(txtMD5.Text);

//compute hash on generated byte array
generatedBytes = md5.ComputeHash(originalBytes);

//display hash bytes as readable string as the hash code generated will contain dash(-)
// to remove that Replace function of Regex is used here....
lblGeneratedMD5.Text = Regex.Replace(BitConverter.ToString(generatedBytes), "-", "");




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Encrypting Selected node in a XML file
Previous Resource: Bit Wise Encryption & decryption
Return to Discussion Resource Index
Post New Resource
Category: Encryption


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use