Standard MD5 .NET implementation

xiaoxiao2021-03-05  21

Key place, process from byte to string

Here is an error!

/ ** /

///

/// Returns 32-bit MD5 hexadecimal encryption /// /// String ////

public

String

GetHexmd5String

String

STRVALUE

{String Strreturn = ""; byte [] data = encoding.unicode.getbytes; md5 md5 = md5cryptoserviceProvider.create (); md5.computehash (data); // The following is a problem from byte to string! For (INT i = 0; I

The result of the settlement is encrypted, writing Java, PHP, ASP and other standard algorithms!

In fact, there is a method of the simplest implementation of MD5 in .NET.

/ ** /

///

/// MD5 encrypted /// /// Encrypted string /// encrypted string

public

Static

String

MD5

String

TocryString)

{Return Formsauthentication.hashPasswordforstoringInConfigfile (TocryString, "MD5");

So, how can I turn from byte to a string? I saw, QuickStart used it.

Bitconverter.tostring

This standard MD5 is written!

public

Static

String

MD5

String

TocryString)

{MD5CryptoServiceProvider hashmd5; hashmd5 = new MD5CryptoServiceProvider (); return BitConverter.ToString (hashmd5.ComputeHash (Encoding.Default.GetBytes (toCryString))) Replace ( "-", "") ToLower ();.. // asp lowercase , Change all characters lowercase}

The result is encrypted, and the same is the same as the standard!

转载请注明原文地址:https://www.9cbs.com/read-38232.html

New Post(0)