Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
MD5 Hashing and Verification
WhatsApp
Banketeshvar Narayan
Nov 14
2015
1.2
k
0
2
using
System;
using
System.Security.Cryptography;
using
System.Text;..................................................................
static
string
GetMd5Hash(
string
textToHash)
{
MD5CryptoServiceProvider md5CryptoServiceProvider =
new
MD5CryptoServiceProvider();
byte
[] data = md5CryptoServiceProvider.ComputeHash(Encoding.Default.GetBytes(textToHash));
StringBuilder sbHashedCode =
new
StringBuilder();
for
(
int
i = 0; i < data.Length; i++)
{
sbHashedCode.Append(data[i].ToString(
"x2"
));
}
return
sbHashedCode.ToString();
}
static
bool
verifyMd5Hash(
string
plainText,
string
hashedValue)
{
return
StringComparer.OrdinalIgnoreCase.Compare(GetMd5Hash(plainText), hashedValue) == 0 ?
true
:
false
;
}
MD5 Hashing
C#
Verification
Up Next
MD5 Hashing and Verification