Hi Antoine,
According to the very first link Google presented
(http://email.about.com/cs/standards/a/base64_encoding.htm), the MapBasic code
should look something along these lines (NOT tested, just from the top of my mind):
Define B64CODES "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrtsuvwxyz0123456789+/"
plainstring = "whatever text you want to encode"
b64output = ""
For i = 1 to Len(plainstring) Step 3
// get 3 x 8 bit values (0-255)
asc1 = Asc(Mid$(plainstring,i,1))
If (i+1) > Len(plainstring) Then asc2 = 0 Else asc2 = Asc(Mid$(plainstring,i+1,1))
End If
If (i+2) > Len(plainstring) Then asc3 = 0 Else asc3 = Asc(Mid$(plainstring,i+2,1))
End If
// create 4 x 6 bit values (0-63)
b64_1 = (asc1 \ 4)
b64_2 = (asc1 mod 4) * 16 + (asc2 \ 16)
b64_3 = (asc2 mod 16) * 4 + (asc3 \ 64)
b64_4 = (asc3 mod 64)
// output 4 x base64 characters (nb! 0- to 1-based)
b64output = b64output + Mid$(B64CODES, b64_1+1, 1)
b64output = b64output + Mid$(B64CODES, b64_2+1, 1)
b64output = b64output + Mid$(B64CODES, b64_3+1, 1)
b64output = b64output + Mid$(B64CODES, b64_4+1, 1)
Next
You need to streamline it somewhat, it's not entirely on a silver platter :-)
According to a convention I've read, base64 encoded texts are usually chuncked in 72
character blocks.
And decoding is vice-versa off course, which I'll leave to you to implement ;-)
Best regards/Med venlig hilsen
Lars V. Nielsen
GisPro, Denmark
http://www.gispro.dk/
----- Original Message -----
From: "Gilbert, Antoine" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 09, 2004 9:54 PM
Subject: MI-L base64 encoding
Hi, sorry for spamming list with my annoying questions
does anyone have a piece of code to encode a string in base 64 (and decode code, of
course)
Antoine
----------------------------------------
Ma bo�te aux lettres est prot�g�e par SPAMfighter
6776 e-mails spam ont �t� bloqu�s jusqu'� maintenant.
T�l�chargez au jour d'hui gratuitement SPAMfighter!
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12108
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12109