Codesnippets > Userlibs [ *.gbal]
encrypt & decrypt strings
Schranz0r:
This gbal encrypt and decrypt a string with a char like "x".
More math inside that functions!
Example:
--- Code: (glbasic) ---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
--- End code ---
You can de/encrypt levelpasswords, variables (integer/floats/strings), etc...
"HOWTO": de/encrypt integer/float variables
--- Code: (glbasic) ---// 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
--- End code ---
Thats it ;)
[attachment deleted by admin]
Kitty Hello:
why do floats crash? You're crypting a string, don't you?
Is it GP2X safe?
Schranz0r:
--- Quote from: Kitty Hello on 2008-Aug-25 ---why do floats crash? You're crypting a string, don't you?
Is it GP2X safe?
--- End quote ---
Whoops, floats are ok :whistle:
--- Code: (glbasic) ---// 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
--- End code ---
Yes, its GP2X safe :)
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?
Navigation
[0] Message Index
[#] Next page
Go to full version