BASIC

Author Topic: Base 64 encoding and decoding  (Read 2359 times)

MrTAToad

  • Guest
Base 64 encoding and decoding
« 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]

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10666
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Base 64 encoding and decoding
« Reply #1 on: 2010-Jun-03 »
Very nice. The V8 will also come with ENCRYPT$() and DECRYPT$() that use a 128 bit encryption algorithm.

MrTAToad

  • Guest
Re: Base 64 encoding and decoding
« Reply #2 on: 2010-Jun-03 »
That'll be useful!

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1752
    • View Profile
    • Homepage
Re: Base 64 encoding and decoding
« Reply #3 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).


MrTAToad

  • Guest
Re: Base 64 encoding and decoding
« Reply #4 on: 2010-Jun-03 »
Obviously these forums are indexed for some reason.  However at least your base 64 stuff is on your website.