Jul
2
2002
Base 64 Encoding/Decoding Class
After seeing the excellent Base64 code on VBspeed (see links below) and comparing it to my own I realised that there was a plenty of room for imporovement in my code. I've managed to speed up the Encoding by 3 times and the decoding by almost 4 times. It's not as fast as the VBspeed's fastest ones but at least it's in the ball park now.
The functions have also been changed. You can now encode either a Byte Array or a String to a String. Likewise a String can be decoded to either a Byte Array or a String. I've done away with reading and writing to files as I've found I've hardly used them.
This code has been revised (12 Jan 2004): Major speed imporvments, new function definitions (as noted above).
Usage
Add Base64Class.cls to your Project
Dim b64 As Base64Class
Dim EncodedText As String
Set b64 = New Base64Class
'To Encode
EncodedText = b64.EncodeString("This is a test String.")
'To Decode
Debug.Print b64.DecodeToString(EncodedText)
Set b64 = Nothing
Downloads
base64.zip - contains: Base64.cls, rfc1521(Base64).txt (4.1 kb)
Links
VBSpeed: : Check out their Base64Dec and Base64Enc sections for some very fast Base64 functions.
The Complete RFC 1521 which includes the definition of Base64 Encoding.
More...