Jump to content

Hex ^ Hex?


Recommended Posts

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

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 by UPSman2
Link to comment
Share on other sites

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 by alex OF DEATH
Link to comment
Share on other sites

  • Moderators

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...