Jump to content

teaDecode problem


Recommended Posts

Posted

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

Posted
please help

Check this maybe it can help you : Click me.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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

  • Moderators
Posted

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) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...