To compute the MD5 hash value of a string in C#, you can use the MD5
class from the System.Security.Cryptography
namespace.
First, convert the string to a byte array using Encoding.UTF8.GetBytes()
method. Then call the ComputeHash()
method of the MD5
class passing in the byte array.
Here's the code:
main.cs474 chars19 lines
Example usage:
main.cs99 chars4 lines
This will output: ed076287532e86365e841e92bfc50d8c
.
gistlibby LogSnag