I need to encrypt any lua script , so I’ll use base64 , I have no idea how to do, someone could help me?
sorry for my english
I need to encrypt any lua script , so I’ll use base64 , I have no idea how to do, someone could help me?
sorry for my english
The standard Lua library “mime” has a base64 encoder in it:
http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0-beta/mime.html
You’re looking at mime.b64() and mime.unb64(). Corona SDK includes this library. You just have to include it:
local mime = require( "mime" ) local encodedString = mime.b64("Hello World"); print( mime.unb64( encodedString ) ) -- prints "Hello World"
Rob
Just a note. Base 64 isn’t encryption
A super simple (and easy to crack) encryption is Rot13 that basically shifts letters around…
function Rotate13(t) local byte\_a, byte\_A = string.byte('a'), string.byte('A') return (string.gsub(t, "[%a]", function (char) local offset = (char \< 'a') and byte\_A or byte\_a local b = string.byte(char) - offset -- 0 to 25 b = math.mod(b + 13, 26) + offset -- Rotate return string.char(b) end )) end
Call it once to encrypt and call it again to decrypt.
The standard Lua library “mime” has a base64 encoder in it:
http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0-beta/mime.html
You’re looking at mime.b64() and mime.unb64(). Corona SDK includes this library. You just have to include it:
local mime = require( "mime" ) local encodedString = mime.b64("Hello World"); print( mime.unb64( encodedString ) ) -- prints "Hello World"
Rob
Just a note. Base 64 isn’t encryption
A super simple (and easy to crack) encryption is Rot13 that basically shifts letters around…
function Rotate13(t) local byte\_a, byte\_A = string.byte('a'), string.byte('A') return (string.gsub(t, "[%a]", function (char) local offset = (char \< 'a') and byte\_A or byte\_a local b = string.byte(char) - offset -- 0 to 25 b = math.mod(b + 13, 26) + offset -- Rotate return string.char(b) end )) end
Call it once to encrypt and call it again to decrypt.