Register for your free account! | Forgot your password?

You last visited: Today at 03:55

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



PasswordCryptography

Discussion on PasswordCryptography within the CO2 Private Server forum part of the Conquer Online 2 category.

Closed Thread
 
Old   #1
 
CriticallyDev's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 87
Received Thanks: 4
PasswordCryptography

Hey everyone.
I was wondering if someone with development experience could explain to me what these written codes on Impulses Base mean and how they work.

The following codes are located inside the password cryptography class. I'm not asking for help however I would find a formal breakdown of the codes to be very helpful.

Code:
static UInt32 LeftRotate(UInt32 var, UInt32 offset)
        {
            UInt32 tmp1, tmp2;
            offset &= 0x1f;
            tmp1 = var >> (int)(32 - offset);
            tmp2 = var << (int)offset;
            tmp2 |= tmp1;
            return tmp2;
        }
Code:
static UInt32 RightRotate(UInt32 var, UInt32 offset)
        {
            UInt32 tmp1, tmp2;
            offset &= 0x1f;
            tmp1 = var << (int)(32 - offset);
            tmp2 = var >> (int)offset;
            tmp2 |= tmp1;
            return tmp2;
        }
Thanks a ton in return everyone ^^.
CriticallyDev is offline  
Old 08/16/2012, 00:50   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Cryptography - Wikipedia, the free encyclopedia
I don't have a username is offline  
Old 08/16/2012, 05:38   #3
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
They're ways to implement roll left/roll right in C#.
Roll left and roll right are bitwise operations that are very similar to left shift and right shift respectively.

Say you have the 4-bit (just to make it simpler) binary number 1001b (in binary, not decimal), left shifting by 2 (as in 1001 << 2) moves the binary digits over two places to the left, but does not roll them over to the right. So this leaves 0100 in binary. Roll left on the other hand rolls the values from the front to the back, meaning 1001 rol 2 would shift it over two with the rollover, leaving 0101. I believe there's an asm instruction to for ror/rol but there's no C# operator corresponding to it (or an IL instruction either? Hybrid?).

That's as simple as I can explain it, but bear in mind the roll over will happen after 32 bits if you're using an int, instead of 4.

As for a breakdown, in the case of LeftRotate, it does a left shift by the amount specified, then just adds (Bitwise or) the part that rolls over.
_tao4229_ is offline  
Thanks
3 Users
Old 08/16/2012, 06:12   #4
 
elite*gold: 0
Join Date: Aug 2012
Posts: 21
Received Thanks: 0
shadow man123 3mel amrece
ameralzlam10 is offline  
Old 08/16/2012, 19:48   #5
 
CriticallyDev's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 87
Received Thanks: 4
Quote:
Originally Posted by I don't have a username View Post
I guess you don't have enough development experience as that's the first thing I searched and actually understood the concept of it's definition.

Quote:
Originally Posted by _tao4229_ View Post
They're ways to implement roll left/roll right in C#.
Roll left and roll right are bitwise operations that are very similar to left shift and right shift respectively.

Say you have the 4-bit (just to make it simpler) binary number 1001b (in binary, not decimal), left shifting by 2 (as in 1001 << 2) moves the binary digits over two places to the left, but does not roll them over to the right. So this leaves 0100 in binary. Roll left on the other hand rolls the values from the front to the back, meaning 1001 rol 2 would shift it over two with the rollover, leaving 0101. I believe there's an asm instruction to for ror/rol but there's no C# operator corresponding to it (or an IL instruction either? Hybrid?).

That's as simple as I can explain it, but bear in mind the roll over will happen after 32 bits if you're using an int, instead of 4.

As for a breakdown, in the case of LeftRotate, it does a left shift by the amount specified, then just adds (Bitwise or) the part that rolls over.
Thank you for that formal breakdown. I'll have another look at how it's used in the source.

P.S: This thread can be closed.
CriticallyDev is offline  
Old 08/16/2012, 21:10   #6
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by CriticallyDev View Post
I guess you don't have enough development experience as that's the first thing I searched and actually understood the concept of it's definition.
No. I have no development experience . How do I code?
I don't have a username is offline  
Thanks
1 User
Old 08/16/2012, 21:36   #7
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by _tao4229_ View Post
They're ways to implement roll left/roll right in C#.
Roll left and roll right are bitwise operations that are very similar to left shift and right shift respectively.

Say you have the 4-bit (just to make it simpler) binary number 1001b (in binary, not decimal), left shifting by 2 (as in 1001 << 2) moves the binary digits over two places to the left, but does not roll them over to the right. So this leaves 0100 in binary. Roll left on the other hand rolls the values from the front to the back, meaning 1001 rol 2 would shift it over two with the rollover, leaving 0101. I believe there's an asm instruction to for ror/rol but there's no C# operator corresponding to it (or an IL instruction either? Hybrid?).

That's as simple as I can explain it, but bear in mind the roll over will happen after 32 bits if you're using an int, instead of 4.

As for a breakdown, in the case of LeftRotate, it does a left shift by the amount specified, then just adds (Bitwise or) the part that rolls over.

In assembly there is the ror and rol instructions. Even at the IL level, there is no instruction for either of these operators, so you must create a wrapper utilizing bit shifts and or to re-create them.
InfamousNoone is offline  
Old 08/17/2012, 04:11   #8
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
Requesting something being closed isn't nearly as effective as reporting your own thread to be closed.
Spirited is offline  
Closed Thread




All times are GMT +1. The time now is 03:56.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.