encrypt & decrypt strings

Previous topic - Next topic

Schranz0r

This gbal encrypt and decrypt a string with a char like "x".
More math inside that functions!

Example:
Code (glbasic) Select
Code$ = "test"

encrypt_code$ = encrypt$(Code$,"x")

decrypt_code$ = decrypt$(encrypt_code$,"x")

WHILE TRUE

PRINT  encrypt_code$,10,10 // test decryped are: 33408-29088-33120-33408
PRINT  decrypt_code$,10,20

SHOWSCREEN
WEND
END


You can de/encrypt levelpasswords, variables (integer/floats/strings), etc... 

"HOWTO": de/encrypt integer/float variables

Code (glbasic) Select
// set variable
my_var = 123

// set variable as string
Code$ = ""+my_var

// encrypt string
encrypt_code$ = encrypt$(Code$,"x")

// decrypt string
decrypt_code$ = decrypt$(encrypt_code$,"x")

// set decrypted string to integer
decrypt_var = decrypt_code$  // Thats GLBasic style :D


WHILE TRUE

// see the results
PRINT  encrypt_code$,10,10
PRINT  decrypt_var,10,30

SHOWSCREEN
WEND
END


Thats it ;)

[attachment deleted by admin]
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

why do floats crash? You're crypting a string, don't you?
Is it GP2X safe?

Schranz0r

#2
Quote from: Kitty Hello on 2008-Aug-25
why do floats crash? You're crypting a string, don't you?
Is it GP2X safe?

Whoops, floats are ok   :whistle:


Code (glbasic) Select

// set variable
my_var = 1876.08

// set variable as String
Code$ = ""+my_var

// encrypt string
encrypt_code$ = encrypt$(Code$,"x")

// decrypt string
decrypt_code$ = decrypt$(encrypt_code$,"x")

// set decrypted string to integer/float
decrypt_var = decrypt_code$


WHILE TRUE

// see the results
PRINT  encrypt_code$,10,10
PRINT  decrypt_var,10,30

SHOWSCREEN
WEND
END


Yes, its GP2X safe :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

Since I can't see how it's done, I can't use it... no use encoding something if I can't decode it on the other side, now is there? :-)

Kitty Hello

There is encrpy _and_ decrypt functions, no?

Schranz0r

Yes Gernot.

this codeexample encrypt a variable to a local variable (encrypt_code$ )
and decrypt to variable (decrypt_code$)

You can encrypt to a file, and decrypt from it for example.
Ther you can save levelpasswords/highscores ...
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

It's a bit hard to call it from PHP now, isn't it?

Schranz0r

yepp, its just for files/offlinemode... sorry
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard