Jump to content
Tuts 4 You

Code C sharp


Recommended Posts

Hello.I am trying to crack basic crackmes for .NET written on C# that can't undestand code.

Please,explain me some ones. Here is function of button clicking..

private void button1_Click(object sender, EventArgs e)
string str = "486752416871754464";
string str2 = "";
while (str.Length > 0)
str2 = str2 + Convert.ToChar(Convert.ToUInt32(str.Substring(0, 2), 0x10)).ToString();
str = str.Substring(2, str.Length - 2);

What the data it converts in the body of cicle while on str2?



What is str.substring with agruments(0,2) and 0x10.ToString();?

Could someone explain this code better please?I am just newbie in classes and methods of C#

Link to comment

Substring is used to remove bits of a string and return that chunk. So in the case of:

str.Substring(0, 2) this means to start at index 0 of str, and take the next two characters and return them as a new string.


So in your case, the first time this is called it would be:

"486752416871754464".Substring(0, 2);


That would return a string of:



As for:

Convert.ToChar(Convert.ToUInt32(str.Substring(0, 2), 0x10)).ToString();


You need to work from the inside out. The first to happen is:

str.Substring(0, 2) which I explained above.


Next is:


Convert.ToUInt32(str.Substring(0, 2), 0x10)


This will convert the number returned from the Substring to a unsigned integer, using base 16 (0x10 is hex for 16).


Last is:

Convert.ToChar( .. ).ToString()


Which means to convert the number result to a char which is a single letter in C#, then convert that char to a string.

  • Like 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...