Base64Coder Object

Description

The base 64 coder can turn a binary blob into an encode string, and vice versa.

Sometimes it is impossible to transfer or transmit raw binary data, by encoding it into text the data can be transmitted without having to worry about embedded nulls or line lengths that could cause incompatabilities with some software.

For example base64 encoding is often used to transmit binary data across SMTP mail networks, another example is that the browser sends the username and password as a base64 encoded string in a header.

Note that base64 is preferred to uuencode/uudecode as it is an exact specification, whereas there are a number of incompatible implementations of uuencode.

Methods

Encode

Decode

Example

 
'first load a picture
Set fi = CreateObject("Toolsack.FileIO")
Set b = fi.LoadFileBinary("C:\temp\picture.jpeg")
 
'encode the blob
Set encoder = CreateObject("Toolsack.Base64Coder")
s = encoder.Encode(b)
 
'decode and save
Set b2 = encoder.Decode(s)
fi.SaveFileBinary "C:\temp\Copy of picture.jpeg", b2, True
 

Samples

Articles



We always want to hear your feedback. Send to feedback@toolsack.com.
© 2000-2001 Toolsack Software Ltd.