Does anyone know how to decrypt the following encryption routine? Basically I have an encryption key, I enter it, then I am asked to enter a 6 letter word which then gets encrypted. How shall I decrypt this?
Thanks
encrypt:
push edx
push ecx
not eax
add eax,0x04
mov edx,eax
pop eax
xor eax,edx
pop edx
rol al,1
rol al,1
rol al,1
sub al,0x02
ret
edit: for the new code, see bottom
This code is weird, but it seems to be doing something like this: (not tested)
The corresponding decrypt would, I think, look like this: (not tested)
Which in assembly could be this: (not tested, and no clutter)
Or you could do it in “mostly 32 bit”: (also not tested)
Nothing at all was tested, but the general strategy I used is this: figure out what the code is doing, and then step by step think about how to undo these things, starting at the end. If there is a rotate left by 3, make a rotate right by 3. If they add 4, subtract 4. XOR and NOT are their own inverses.
Because I got the key and the data mixed up I got it wrong. Actually, it should be this: (also not tested)
Because the operations done on the key should not be the inverses.