sd_procs update: base 64 encoding and nybble colors in Off Topic
|
|
I've just updated sd_procs with a handful of procs for converting between text, hexidecimal text and base 64 encoded text. Base 64 encoding is the format that BYOND uses when writing a binary file as text with the ExportText() proc.
I first became interested in base 64 encoding for decrypting dmi files in BYOND. (That project is still on a back burner.) Thanks to wikipedia's documentation of the format, I made a base 64 to hex converter in DM.
Today I was working with Mike H's RC5 library and wondering how to minimize the bloating of the encoded string. Once I realized that his library was returning a hex string, it all clicked into place. I can cut the string length by 1/3 if I convert it to base 64. It's still 25% larger than the original string, but it is quite an improvement and URL safe. Well... I thought it was significant! :)
The nybble colors have been in sd_procs for a while, but I didn't give them a proper introduction when I made the update back in April. These procs convert between a 3 or 6 character RGB hexidecimal code and a 4 bit (aka nybble) color code. Obviously there is quite a bit of detail lost in the conversion, but it's great if you have to store a lot of approximated color info in as small a space as possible. I use it for the colored text maps in Darke Dungeon.
|
My "encryption" amounted to rot13(encode_base64(rot13(text))). "Decryption" was rot13(decode_base64(rot13(text))). This would prevent casual users from just being able to apply a base64 decoder in order to read the passwords file, which I figured was "safe enough".
I think Lummox JR also has a base64 codec which he hasn't released or publicly mentioned.