Base64 decode data: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
No edit summary |
||
Line 709: | Line 709: | ||
To err is human, but to really foul things up you need a computer. |
To err is human, but to really foul things up you need a computer. |
||
-- Paul R. Ehrlich |
-- Paul R. Ehrlich |
||
</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> |
</pre> |
||