StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
soooulp  
#1 Posted : Friday, November 4, 2022 3:52:38 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 154
China

Thanks: 46 times
Was thanked: 21 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

thanks 1 user thanked soooulp for this useful post.
Charles on 11/4/2022(UTC)
soooulp  
#2 Posted : Friday, November 4, 2022 5:14:21 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 154
China

Thanks: 46 times
Was thanked: 21 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("-","");
Users browsing this topic
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.