Previous - Base64 Conversion Section Home - Base64 Conversion Next - b64decode


b64encode ( )

Encodes an ASCII string into a Base64 encoded string

Usage:

b64encode (object me, string binaryString)

Parameters:

binaryString (string) - Converts a string with into Base64 encoding

Returns:

(string) - base64 encoded string

Example1:

--  example demonstrates how to encode a jpg with the help of file IO functions
xtRose = xtra("Rosetta").new( )
-- open an jpg file
xtRose.ioOpen( "C:\tmp.jpg", 1 )
nSize = xtRose.ioSize( )
strFile = xtRose.ioRead( nSize )
xtRose.ioClose( )
-- encode the jpg string with base 64 encoding
strB64 = xtRose.b64encode( strFile )
-- save the encoded string onto the hard disk
xtRose.ioOpen( "C:\b64enc.dat", 2 )
xtRose.ioWrite( strB64 )
xtRose.ioClose( )

Example2:

-- example shows how one could construct a binary string in Director
strTmp = "blah"
put numToChar(0) after strTmp
put numToChar(217) after strTmp
put numToChar(199) after strTmp
put "hello world" after strTmp
xtRose = xtra("Rosetta").new( )
strB64 = xtRose.b64encode( strTmp )

Notes:

 

See Also:

ioOpen


Previous - Base64 Conversion Section Home - Base64 Conversion Next - b64decode