GLBasic forum

Codesnippets => Math => Topic started by: MrTAToad on 2010-Jun-02

Title: Base 64 encoding and decoding
Post by: MrTAToad on 2010-Jun-02
This is a conversion of Synesis Software Base-64 C system to GLBasic.  The general rule is to choose a set of 64 characters that is both part of a subset common to most encodings, and also printable. This combination leaves the data unlikely to be modified in transit through systems, such as email, which were traditionally not 8-bit clean.

So, the array of integers 1,2,3,4,5,6,7,8,9,10 comes out as :

AQAAAAIAAAADAAAABAAAAAUA
AAAGAAAABwAAAAgAAAAJAAAA
CgAAAA==

or

AQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAA==

[attachment deleted by admin]
Title: Re: Base 64 encoding and decoding
Post by: Kitty Hello on 2010-Jun-03
Very nice. The V8 will also come with ENCRYPT$() and DECRYPT$() that use a 128 bit encryption algorithm.
Title: Re: Base 64 encoding and decoding
Post by: MrTAToad on 2010-Jun-03
That'll be useful!
Title: Re: Base 64 encoding and decoding
Post by: Moru on 2010-Jun-03
That's funny, I'm sure I wrote a Base 64 encode/decode library purely in GLBasic a couple of years ago but the searchfunction on the boards can't find it. Actually it won't even find this post.

Anyway, see my version here:
http://gamecorner.110mb.com/index.php?page=base64-encode-decode-library

It has file upload to a PHP-script with SQL-database backup, RLE encoding, you can use both a string or an array to encode and you can encode as normal or for URL (different rules).

Title: Re: Base 64 encoding and decoding
Post by: MrTAToad on 2010-Jun-03
Obviously these forums are indexed for some reason.  However at least your base 64 stuff is on your website.