haron4igg Posted June 1, 2017 Share Posted June 1, 2017 (edited) Hello, Can somebody explain me, how could be that possible: local file = fileOpen("loading.dds") local size = fileGetSize(file) local raw = fileRead(file, size) fileClose(file) local encoded = teaEncode(raw, "0123456789ABCDEF") local dencoded = teaDecode(encoded, "0123456789ABCDEF") outputDebugString("Raw: " .. string.len(raw)) outputDebugString("Encoded: " .. string.len(encoded)) outputDebugString("Decoded: " .. string.len(dencoded)) if dencoded == raw then outputDebugString("Test PASSED") else outputDebugString("Test FAILED") end Result: Client v1.5.4-release-11354 Oh... never-mind. Tea works only with text-data. Not binary. In order to fix this - wrap data in-to Base64 before encoding. And unwrap after decode. local encoded = teaEncode(base64Encode(raw), "0123456789ABCDEF") local dencoded = base64Decode(teaDecode(encoded, "0123456789ABCDEF")) outputDebugString("Raw: " .. string.len(raw)) outputDebugString("Encoded: " .. string.len(encoded)) outputDebugString("Decoded: " .. string.len(dencoded)) if dencoded == raw then outputDebugString("Test PASSED") else outputDebugString("Test FAILED") end Edited June 1, 2017 by haron4igg Link to comment
koragg Posted June 1, 2017 Share Posted June 1, 2017 (edited) I feel awkward that this is the first time I even hear about some functions in this post And I'm not new to MTA or LUA heh Edited June 1, 2017 by koragg Link to comment
MTA Team botder Posted June 1, 2017 MTA Team Share Posted June 1, 2017 You have to base64 encode the binary file data before you put the content through teaEncode. Look at the second code example: https://wiki.multitheftauto.com/wiki/TeaEncode#Example Link to comment
Addlibs Posted June 1, 2017 Share Posted June 1, 2017 1 hour ago, Necktrox said: You have to base64 encode the binary file data before you put the content through teaEncode. Look at the second code example: https://wiki.multitheftauto.com/wiki/TeaEncode#Example He already figured it out over 8 hours ago (last update of post) 1 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