Decrypt String:

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

Decrypt String:

Post 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
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Decrypt String:

Post 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?
User avatar
max_aigneraigner@web.de
User
User
Posts: 67
Joined: Sun Nov 02, 2008 10:37 pm
Location: Bavaria
Contact:

Re: Decrypt String:

Post 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
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Decrypt String:

Post by cas »

No problem.
But next time post that kinds of questions in Coding Questions, not Off Topic section. :wink:
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Re: Decrypt String:

Post 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)?
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Decrypt String:

Post by cas »

225 is mask used for XOR-ing. It is like decryption password.
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Re: Decrypt String:

Post 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:
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Decrypt String:

Post 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. :)
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Re: Decrypt String:

Post 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.
Post Reply