Page 1 of 1

Decrypt String:

Posted: Wed Feb 09, 2011 12:22 am
by max_aigneraigner@web.de
Hi forum, coult you please help me decrypting that stirng:

Code: Select all

0-terminierter ascii-string..:
char s[]={0x90,0x94,0x80,0x80,0x8a,0xc0,0xe1};
the extracted bytes (6 and the 0-terminating byte) are the following:

; 144
; 148
; 128
; 128
; 138
; 192
; 225

so 225 must be 0..

I don't know the result..

I tried that:

Code: Select all

schlussel.s + Chr( $90) + Chr($94) + Chr(128) + Chr(128) + Chr(138) + Chr( 192) + Chr(225)
schlussel.s = Chr( 225-$90) + Chr(225-$94) + Chr(225-128) + Chr(225-128) + Chr(225-138) + Chr( 225-192) + Chr(225-225)
Debug schlussel
SetClipboardText ( schlussel)
schlussel.s = Chr( $90-225) + Chr($94-225) + Chr(128-225) + Chr(128-225) + Chr(138-225) + Chr( 192-225) + Chr(225-225)
Debug schlussel 

yours max

Re: Decrypt String:

Posted: Wed Feb 09, 2011 1:27 am
by cas
It would be helpful if you said what decrypted text you expect or what encryption algorithm is used.
Here i tried simple XOR with 225:

Code: Select all

EnableExplicit

Procedure.s mydecrypt(encrypted.s)
  Protected decrypted.s=""
  Protected len=Len(encrypted.s)
  Protected k
  
  For k=1 To len/2
    decrypted.s+Chr(Val("$"+PeekS(@encrypted+(k-1)*2,2)) ! 225)
  Next
  
  ProcedureReturn decrypted.s
EndProcedure

Debug mydecrypt("909480808ac0e1")
Is this what you are looking for?

Re: Decrypt String:

Posted: Wed Feb 09, 2011 1:33 am
by max_aigneraigner@web.de
that's it..
thank you..! thanks cas!
I really have to admit that I am impressed..
I didn't get it so far..

thank you again :)

yours
max

Re: Decrypt String:

Posted: Wed Feb 09, 2011 2:19 am
by cas
No problem.
But next time post that kinds of questions in Coding Questions, not Off Topic section. :wink:

Re: Decrypt String:

Posted: Wed Feb 09, 2011 2:26 am
by Baldrick
cas wrote: Here i tried simple XOR with 225:
@cas,
Just as a matter of interest, what is the signifigance of the 225 (11100001)?

Re: Decrypt String:

Posted: Wed Feb 09, 2011 2:31 am
by cas
225 is mask used for XOR-ing. It is like decryption password.

Re: Decrypt String:

Posted: Wed Feb 09, 2011 2:48 am
by Baldrick
cas wrote:225 is mask used for XOR-ing. It is like decryption password.
lol, np cas. I understand the masking. Just wondering why is 225 used for this as the number has very little meaning to me. :oops:

Re: Decrypt String:

Posted: Wed Feb 09, 2011 3:12 am
by cas
In 1st post max wrote that his encrypted string is 0-terminated ascii-string.
So we know two things: last character when encrypted is 0xe1 (225) and we know that when 0xe1 is decrypted then it must be 0.
And for last character to be 0 when decrypted, we need to XOR him with itself (225!225=0).

I hope we understood each other now. :)

Re: Decrypt String:

Posted: Wed Feb 09, 2011 4:35 am
by Baldrick
thanks cas. Makes sense now. :)
I would have been caught out for a long time as I would have been happy to say the null termination was just the cut off that we never see in strings as end of string indicator.