Page 1 of 1

new data command

Posted: Thu Jun 02, 2005 5:30 pm
by DoubleDutch
A new data statement that will xor the values in memory before they are stored.

eg:

Code: Select all

DATAXOR   "secret","This text will be exored with the word secret"
would produce a scrambled data that would have to be xored with "secret" before it would be readable.

There would have to some kind of new delimiter though - cause an xor may produce a value of zero (end of string).

This command would be great for hiding strings of text in a program.

Posted: Thu Jun 02, 2005 5:45 pm
by Droopy
Like this ?

Code: Select all

; PureBasic 3.93
; Encode a String with another String ( Key )
; Just a simple Xor Encoding

Procedure.s XorEncode(Key.s,String.s)
  
  For n=1 To Len(String)
    ChrString=Asc(Mid(String,n,1))
    ChrKey=Asc(Mid(Key,Ptr+1,1))
    If ChrString=ChrKey
      ChrCrypt=ChrString
    Else
      ChrCrypt=ChrString ! ChrKey
    EndIf
    
    Retour.s+Chr(ChrCrypt)
    Ptr+1
    If Ptr >Len(Key) : Ptr=0 : EndIf
  Next
  ProcedureReturn Retour
EndProcedure

;/ Test
Key.s="SuperKey"
xx.s= XorEncode(Key,"This is the String to Crypt")
Debug xx
Debug XorEncode(Key,xx)

Posted: Thu Jun 02, 2005 7:25 pm
by Trond
This is so paranoid. If you really need something secure, you can do it manually with that very string.

Posted: Thu Jun 02, 2005 10:26 pm
by DoubleDutch
nope, I meant so that the data is xored at compile time, for you to un xor at run time...

uc?