I need to obfuscate (encode-decode) some large string

Everything else that doesn't fall into one of the other PB categories.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

I need to obfuscate (encode-decode) some large string

Post by ricardo »

Hello

I need to obfuscate (encode-decode) some large string to make it unreadable if someone rightclick my .exe.
But its large, very large (2 pages of a javascript).

Need to be able to read itself the .exe and decode it. Dont want to use well know methods but some custom ones (to make harder the decode by curios)... any suggestion?

Thanks in advance.
ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

ATM im using this idea:

Code: Select all

Procedure.s Encode(string$,Nn)
    For Char = 1 To Len(string$)
        Letra$ = Mid(string$,Char,1)
        EncNum+1
        Codificado$ = Codificado$ + Chr(Asc(Letra$) + EncNum)
        If EncNum > Nn
            EncNum = 0
        EndIf
    Next
    ProcedureReturn Codificado$
EndProcedure

Procedure.s Decode(string$,Nn)
    For Char = 1 To Len(string$)
        Letra$ = Mid(string$,Char,1)
        EncNum+1
        Codificado$ = Codificado$ + Chr(Asc(Letra$) - EncNum)
        If EncNum > Nn
            EncNum = 0
        EndIf
    Next
    ProcedureReturn Codificado$
EndProcedure

It works, but dont know if my idea is primitive, there are better ones, etc.

The point is that not alwasy letter 'A' will replaced by the same on the encoded string. I know this can be hacked, but im just doing this for hidde the code, not for avoiding professional hackers, just avoid curios people.

Then, hello world, hello world, hello world encoding with Nn as 3, gets igopp"zssng0!jhpmq#{ptoh-"kimnr$xqupe and encoding it with Nn as 19 gets igopt&~w{vo8-vt|}
ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

This could be better:

Code: Select all

Procedure.s Encode(string$,Nn,Added)
    For Char = 1 To Len(string$)
        Letra$ = Mid(string$,Char,1)
        EncNum+Added
        Codificado$ = Codificado$ + Chr(Asc(Letra$) + EncNum)
        If EncNum > Nn
            EncNum = 0
        EndIf
    Next
    SetClipboardText(Codificado$)
    ProcedureReturn Codificado$
EndProcedure

Procedure.s Decode(string$,Nn,Added)
    For Char = 1 To Len(string$)
        Letra$ = Mid(string$,Char,1)
        EncNum+Added
        Codificado$ = Codificado$ + Chr(Asc(Letra$) - EncNum)
        If EncNum > Nn
            EncNum = 0
        EndIf
    Next
    ProcedureReturn Codificado$
EndProcedure
Using Nn as 19 and Added as 2
hello world, hello world, hello world becomes:
jirty,…„€f0&poxz2‹qvrl6,vu~€q$}w|xr

Using Nn as 19 and Added as 3
hello world, hello world, hello world becomes:
kkux~2Œrxup;2}hru{/‰„urm8/zzorx,†
Last edited by ricardo on Tue Mar 29, 2005 5:43 am, edited 1 time in total.
ARGENTINA WORLD CHAMPION
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I think a very simple way would be to use the packer commands to compress the data.
The result is absolutely unreadable, and you even save some bytes :)
quidquid Latine dictum sit altum videtur
Post Reply