WinniePh Posted April 13, 2013 Share Posted April 13, 2013 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
atom0s Posted April 13, 2013 Share Posted April 13, 2013 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:"48" 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. 2 Link to comment
WinniePh Posted April 13, 2013 Author Share Posted April 13, 2013 atom0s,great thanks for fast posting.I undestood your lesson Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now