StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
Where is the problem that gets the wrong result from converting a string to MD5?
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
I need to convert a string to MD5 in 32-character, and I find this , but the result is all number. The string 20220519001221642Create a simple console project16675763820352aH9stuyoUUG9SSI1wFE I get the result in the Console 60249243151184372358126242124906614514611 I want the result like 3cf9f397b825eb087ef27c5a4291920b Code:var salt = (new Date).getTime();//Time
var text = "Create a simple console project";
var cl = '20220519001221642' + text + salt + '2aH9stuyoUUG9SSI1wFE';
var md5 = clr.System.Security.Cryptography.MD5.Create();
var s = md5.ComputeHash(clr.System.Text.Encoding.UTF8.GetBytes(cl));
var sign = new clr.System.Text.StringBuilder();
for (n = 0; n < s.Length; n++)
{
//sign.Append(s[n].ToString("x2"));
sign.Append(s[n]);
}
StrokesPlus.Console.Log(sign.ToString());
StrokesPlus.Console.Log(cl);
Edited by user Friday, November 4, 2022 4:16:30 PM(UTC)
| Reason: Not specified
|
1 user thanked soooulp for this useful post.
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Solved. Change to this line.
string hash = BitConverter.ToString(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes("THIS STRING TO MD5"))).Replace("-","");
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
Where is the problem that gets the wrong result from converting a string to MD5?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close