Hide literal strings in compiled exe

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Hide literal strings in compiled exe

Post by kenmo »

D'oh, I missed the post where you mentioned you already wrote a pre-processor. Sorry!

It would be an interesting feature... (But, realistically, it would be pretty low on the PB team's list of priorities in the near future!)
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: Hide literal strings in compiled exe

Post by em_uk »

Hi,

I sometimes need to hardcode stuff into an executable I dont want someone to easily be able to view, I do this :

Code: Select all

;needs Droopy Lib for SelfEncryption

Procedure.s PassToHex(passworda$="data",enc=#True)
  If enc
    tbufa$=SelfEncryption(passworda$,#True)
    passworda$=tbufa$
    tlen=Len(passworda$) : loc = 0
    tbuf$="" : loc = 0 
    For n = 0 To tlen-1
      loc=@passworda$+n
      result$= RSet(Hex(PeekB(loc)),2,"0")
      tbuf$+result$      
    Next    
    SetClipboardText("key$="+#DQUOTE$+tbuf$+#DQUOTE$)    
    ProcedureReturn tbuf$       
  Else    
    tlen=Len(passworda$)
    tbuf$=""
    For n= 0 To tlen
      n=n+1
      loc=@passworda$+n
      bufa$=Mid(passworda$,n,2)
      result$=Chr(Val("$"+bufa$))
      tbuf$+result$    
    Next
    tbufa$=SelfEncryption(tbuf$,#False)    
    ProcedureReturn tbufa$
  EndIf
EndProcedure

; create me an encoded key

key$="This Key will be stored"

Debug "Encrypted"

Debug PassToHex(key$,#True) ; the encoded key will be copied to clipboard as key$="xxxx" etc.

; decode me some key
    
key$="432B4231115A3F466611781478583A5F7F0C7817656501" 

Debug PassToHex(key$,#False)

MessageRequester("Test", PassToHex(key$,#False))

Any determined hacker could easily use olydbg to figure this out though, but it keeps most people out.

Cheers
----

R Tape loading error, 0:1
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Hide literal strings in compiled exe

Post by DoubleDutch »

+1 for some way of doing this.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply