new data command

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

new data command

Post 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.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post 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)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

This is so paranoid. If you really need something secure, you can do it manually with that very string.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

nope, I meant so that the data is xored at compile time, for you to un xor at run time...

uc?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply