alex OF DEATH Posted July 7, 2008 Share Posted July 7, 2008 Well, I'm trying to do some relatively simple math here.. but not with integers. I have an array with a series of strings such as "FF" and "0C" .. which, as you probably know, are hex bytes. Now, using each hex byte from the array, I want to take it to the power of 0x61. Technically, I'm doing this: 0x61 ^ "FF" ... But FF is a string, and not actual hex. Even if I add 0x.. it's still "0xFF" (which is still a string) I tried making each byte a decimal with Dec(),, then doing 97 ^ Dec($arraywithhexinstringform) but.. it usually just returned "#INF" (?) Anybody see a way to do this? here's what I have right now: Thanks in advance #Include <String.au3> #Include <WinAPI.au3> global $pakbytes[13] global $decryptedpak[13] $recv = "0x0B00C5661A0F6160610000" ; the hex $recvpak = StringTrimLeft ( $recv, 0 ) ;nevermind this $size = StringLen ($recvpak) / 2 ;how many bytes (2 chars per byte) for $i = 0 to $size $pakbytes[$i] = StringLeft ( $recvpak, 2 ) ;for each byte (two characters), add into $pakbytes[] $recvpak = StringTrimLeft( $recvpak, 2 ) next for $i = 1 to ubound($pakbytes) - 1 ; consolewrite($pakbytes[$i] & @CR) next ;consoleWrite("DECRYPTED::" & @CR) for $i = 2 to ubound($pakbytes) - 2 ;for i to how many bytes (except first two and last two) $decryptedpak[$i] = 0x61 ^ $pakbytes[$i] consoleWrite($decryptedpak[$i] & @CR) next Link to comment Share on other sites More sharing options...
UPSman2 Posted July 7, 2008 Share Posted July 7, 2008 (edited) MsgBox(0,"",97^255) returns infinity too, only because its a huge number (its equalivanlt to "0x61"^"0xFF") so its probably not your math or way of conversion that is messing up it's just that autoit doesn't support such large numbers Edited July 7, 2008 by UPSman2 Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 7, 2008 Author Share Posted July 7, 2008 MsgBox(0,"",97^255)returns infinity too, only because its a huge number (its equalivanlt to "0x61"^"0xFF")So.. is there anything I can do? Link to comment Share on other sites More sharing options...
UPSman2 Posted July 7, 2008 Share Posted July 7, 2008 So.. is there anything I can do?i don't know any solution but i'm not that great at math nor autoit... so there might be an answer but i don't know it Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 7, 2008 Author Share Posted July 7, 2008 (edited) You tell me- I'm trying to convert this: unsigned short paksize=(*((unsigned short*)&packet[0])) - 2; for(int i=2; i<paksize; i++) { packet[i] = 0x61 ^ packet[i]; } I have almost zero practical experience with any variant of C. --??? Someone's post here vanished. Oh well. Edited July 7, 2008 by alex OF DEATH Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 7, 2008 Moderators Share Posted July 7, 2008 You tell me- I'm trying to convert this: unsigned short paksize=(*((unsigned short*)&packet[0])) - 2; for(int i=2; i<paksize; i++) { packet[i] = 0x61 ^ packet[i]; } I have almost zero practical experience with any variant of C. --??? Someone's post here vanished. Oh well.Ummm... in C ... ^ = XOr (Could have been found with google) $packet[$i] = BitXOr(0x61, $packet[$i]) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 7, 2008 Share Posted July 7, 2008 Ah. I had actually asked this but then deleted my post. Maybe I should have kept it... Yes, the ^ symbol in C++ is not to-the-power-of. It is XOR. Link to comment Share on other sites More sharing options...
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