Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: String -> MD5 -> Hex

Tags:

c#

hash

md5

in languages like PHP or Python there are convenient functions to turn an input string into an output string that is the HEXed representation of it.

I find it a very common and useful task (password storing and checking, checksum of file content..), but in .NET, as far as I know, you can only work on byte streams.

A function to do the work is easy to put on (eg http://blog.stevex.net/index.php/c-code-snippet-creating-an-md5-hash-string/), but I'd like to know if I'm missing something, using the wrong pattern or there is simply no such thing in .NET.

Thanks

like image 381
pistacchio Avatar asked Dec 03 '22 15:12

pistacchio


1 Answers

The method you linked to seems right, a slightly different method is showed on the MSDN C# FAQ

A comment suggests you can use:

System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string, "MD5");
like image 146
Dykam Avatar answered Dec 21 '22 04:12

Dykam