This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LBPHacker's profile picture

Have Some Base64

Started by LBPHacker, 08 October 2013 - 01:50 PM
LBPHacker #1
Posted 08 October 2013 - 03:50 PM
Yeah, that. Base64 encoding and decoding. It's useful when one wants to save binary data, because CC can't distinguish the CR (0x0D) from the LF (0x0A) character. (To be honest, I was bored.)

Remember, this is not any kind of encryption or hashing. This is just an awesome way of converting three octets into four printable characters.

For the ones who don't know what Base64 is.

And for the ones who actually would like to use this (pastebin get rsd5qnEW base64).

EDIT: Updated code on Pastebin.
Edited on 09 April 2014 - 02:17 PM
Anavrins #2
Posted 08 October 2013 - 04:31 PM
That's nice, but it seems like you forgot to define "base64Chars" and "base64Values".
I get this error upon encoding : "7: attempt to index ? (a nil value)"
and this one when decoding : "19: attempt to index ? (a nil value)"
PixelToast #3
Posted 08 October 2013 - 11:00 PM
https://gist.github....iller64/6895559
i got bored, and decided to make one that was a bit more optimized
warning, cluster%^&* code

o=o..string.char((_unb64[txt:sub(l1,l1)]*4)+math.floor(d1/16),((d1%16)*16)+math.floor(d2/4),((d2%4)*64)+_unb64[txt:sub(l1+3,l1+3)])
use it if you want :P/>
LBPHacker #4
Posted 09 October 2013 - 12:14 AM
Holy cow, I indeed did! Thing is, I was writing some kind of an encryption API. The daclarations are the first few lines of that and I copied over only the relevant functions :P/> Sorry…

Updated code on pastebin.
LBPHacker #5
Posted 09 April 2014 - 04:20 PM
*sigh* I found this thread yesterday, and what I saw made me flinch (the code; oh, the horror). So, yeah, I've uploaded a way better implementation of the Base64 method. Same Pastebin ID; edited OP.
apemanzilla #6
Posted 09 April 2014 - 04:53 PM
*sigh* I found this thread yesterday, and what I saw made me flinch (the code; oh, the horror). So, yeah, I've uploaded a way better implementation of the Base64 method. Same Pastebin ID; edited OP.
It's like looking at baby pictures :P/>

And finally, a useful necro :D/>