xTravax Posted May 9, 2015 Share Posted May 9, 2015 hi i am trying to encode image code with tea function and then later when i need it i decode it but it doesnt work local file = fileOpen("rec.jpg") local content = fileRead(file,fileGetSize(file)) local encode = teaEncode(content,"#qa$aJOAio4jikj!") fileClose(file) fileDelete("rec.jpg") local file = fileCreate("rec.jpg") fileWrite(file,encode) fileClose(file) function restoreFile() fileDelete("rec.jpg") local image = fileCreate("rec.jpg") fileWrite(image,teaDecode(encode,"#qa$aJOAio4jikj!")) fileClose(image) end addCommandHandler("restore",restoreFile) you can try any picture and it wont work for unknown reason when it "restores" the file it makes 4 bytes long text like ˙Ř˙ŕ please help Link to comment
Walid Posted May 9, 2015 Share Posted May 9, 2015 please help Check this maybe it can help you : Click me. Link to comment
xTravax Posted May 10, 2015 Author Share Posted May 10, 2015 yes i am using teaEncode already and i didnt need that topic to get teaEncode idea by myself but this doesnt work please help someone Link to comment
Scripting Moderators Sarrum Posted May 10, 2015 Scripting Moderators Share Posted May 10, 2015 Try encode binary data to base64 and decode base64 encoded string back to binary. local file = fileOpen("rec.jpg") local content = fileRead(file,fileGetSize(file)) --local encode = teaEncode(content,"#qa$aJOAio4jikj!") local encode = teaEncode(base64Encode(content),"#qa$aJOAio4jikj!") fileClose(file) fileDelete("rec.jpg") local file = fileCreate("rec.jpg") fileWrite(file,encode) fileClose(file) function restoreFile() fileDelete("rec.jpg") local image = fileCreate("rec.jpg") --fileWrite(image,teaDecode(encode,"#qa$aJOAio4jikj!")) fileWrite(image,base64Decode(teaDecode(encode,"#qa$aJOAio4jikj!"))) fileClose(image) end addCommandHandler("restore",restoreFile) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now