Base64 encode data: Difference between revisions

Content added Content deleted
(→‎{{header|Frink}}: Reformatted base-64 output)
No edit summary
Line 902: Line 902:
M2ZlYTViYzI5ZS5pY28ucG5nBect2gAAAABJRU5ErkJggg==
M2ZlYTViYzI5ZS5pY28ucG5nBect2gAAAABJRU5ErkJggg==
</pre>
</pre>


=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSlog.incl"

local fn EncodeStringAsBase64( stringToEncode as CFStringRef ) as CFStringRef
CFStringRef encodedBase64Str = NULL
CFDataRef dataToEncode = fn StringData( stringToEncode, NSUTF8StringEncoding )
encodedBase64Str = fn DataBase64EncodedString( dataToEncode, 0 )
end fn = encodedBase64Str


local fn DecodeBase64String( base64String as CFStringRef ) as CFStringRef
CFStringRef decodedString = NULL
CFDataRef encodedData = fn DataWithBase64EncodedString( base64String, NSDataBase64DecodingIgnoreUnknownCharacters )
decodedString = fn StringWithData( encodedData, NSUTF8StringEncoding )
end fn = decodedString


CFStringRef originalString, encodedBase64String, decodedBase64String

originalString = @"This is a test string to be encoded as Base64 and then decoded."
NSLog( @"This is the original string:\n\t%@\n", originalString )

encodedBase64String = fn EncodeStringAsBase64( originalString )
NSLog( @"This is the original string encoded as Base84:\n\t%@\n", encodedBase64String )

decodedBase64String = fn DecodeBase64String( encodedBase64String )
NSLog( @"This is the Base64 string decoded:\n\t%@", decodedBase64String )

HandleEvents
</syntaxhighlight>
{{output}}
<pre>
This is the original string:
This is a test string to be encoded as Base64 and then decoded.

This is the original string encoded as Base84:
VGhpcyBpcyBhIHRlc3Qgc3RyaW5nIHRvIGJlIGVuY29kZWQgYXMgQmFzZTY0IGFuZCB0aGVuIGRlY29kZWQu

This is the Base64 string decoded:
This is a test string to be encoded as Base64 and then decoded.
</pre>




=={{header|Go}}==
=={{header|Go}}==