MD5 is an acronym for Message-Digest 5-- a fast and powerful method of increasing security to file transfers and message request transfers.
The way it works is the user enters an input string, and the md5 algorithm will generate a 32-character string in hexadecimal characters. The characters will always be hexidecimal, and the string will always be 32 characters in length.
Once a string is hashed into an md5 hash, it cannot be unhashed via any "un-md5" algorithm. The only way is to use an MD5 cracker tool, which queries a large database of strings and their associated md5 hashes.
Once your md5 hash code is generated, you can deliver it to the expected receiver and they can use that hash to match against their result of performing an md5 hash on their own values. If the hashes match, then you can be confident that the data was sent correctly.
CODE :
using System.Text;
using System.Security.Cryptography;
public static string ConvertStringtoMD5(string strword)
{
MD5 md5 = MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(strword);
byte[] hash = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("x2"));
}
return sb.ToString();
}
Không có nhận xét nào:
Đăng nhận xét