ybox2 base64 encoder

Comments Off

I have created a functional base64 encoding method for the ybox.

It’s not ideal as it requires the programmer to declare an output array large enough to hold the result of the encoding procedure. I tried everything I could think of to avoid this by using the size of the input string (strsize(in_ptr)*(4/3)) to store the output, but I couldn’t get it.

Download the updated base64.spin.

Sample usage:

CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

OBJ
text : "TV_Text"
b64  : "base64"

VAR
byte outstring[25]

PUB start | i
text.start(12)

b64.encode(string("admin:admin"), @outstring)
text.str(@outstring)
text.out(13)

b64.encode(string("admin:password"), @outstring)
text.str(@outstring)
text.out(13)

b64.encode(string("Die SPIN Die!"), @outstring)
text.str(@outstring)
text.out(13)

b64.encode(string("meh"), @outstring)
text.str(@outstring)

repeat

And a sample image from the above code:

If anyone has any tips that can help get rid of the need to declare the output variable’s size, please let me know. Tim

Comments are closed.

imagitronics.org is Digg proof thanks to caching by WP Super Cache