Jump to content

BlitzMax/Modules/BaH/Base64

From Wikibooks, open books for an open world

Base64 is a Public Domain Base64 Encoder/Decoder by Robert Harder. See Base64 for Java source.

Types

[edit | edit source]

TBase64

[edit | edit source]

Encode/Decode Base64 data.

To Encode :

SuperStrict
Import BaH.Base64

Local someData:String = "Woo! BlitzMax Modules rock!"
Local encoded:String = TBase64.Encode(someData, someData.length)
Print "Encoded : " + encoded

To Decode :

SuperStrict
Import BaH.Base64

Local encodedData:String = "V29vISBCbGl0ek1heCBNb2R1bGVzIHJvY2sh"
Local data:Byte[] = TBase64.Decode(encodedData)
Local decoded:String = String.FromBytes(data, data.length)
Print "Decoded : " + decoded
Functions
  • Encode
  • Decode

TBase64: Functions

[edit | edit source]
Encode

Function Encode:String( source:Byte Ptr, length:Int, offset:Int = 0, options:Int = 0)

Description: Encode byte data to a Base64 encoded String, starting at offset of length bytes.

Decode

Function Decode:Byte[]( source:String, offset:Int = 0, options:Int = 0 )

Description: Decode Base64 encoded String to an array of Bytes, starting at offset.