Email or username:

Password:

Forgot your password?
Devine Lu Linvega

Wrote a little program(200 bytes) to encode binary files into base64.

I've come across base64 often in the past, I knew it used some sort of ascii table for packing binary data into text, but it's the first time that I implement it myself.

doc: wiki.xxiivv.com/site/base64.ht
src: git.sr.ht/~rabbits/uxn-utils/t

Source code in left for base64 encoding. The entire codebase is just a few lines.
4 comments
Lac Meod

@neauoire I don't see the handling of the padding and the alternate MME table for base64 url encoding (that has become a silent de facto norm because of sending binary other HTTP GET :D )

Devine Lu Linvega

@LaFoulqueDuVexin I was wondering about the padding, I'm writing a decoder, and I don't see the point of it, is it really needed? You can infer the padding based on the queue length.

Lac Meod

@neauoire
If I take my hat of RFC pedantic : THIS IS A SIN, padding is mandatory.

Well RFC pedantic might point out that all = in excess MAY be ignored (which decoders often accept (but not always)).

I often add "===" after a b64encoded string when I am in the mood for seeing the world burn. And it's fun.

I am not convinced by the rationale of the mandatory padding in the RFC in the first place to be honest.

Devine Lu Linvega

@LaFoulqueDuVexin I think the padding may come in handy when there is no way to detect the end of stream.

Go Up