Convert to Base64: Difference between revisions

From Cuis CookBook
Jump to navigation Jump to search
(imported material)
 
(syntax hilight)
 
Line 4: Line 4:


=== Solution ===
=== Solution ===
Convert to ByteArray and then encode using #base64Encoded:
Convert to ByteArray and then encode using #base64Encoded:<syntaxhighlight lang="smalltalk">
'Hello World' asByteArray base64Encoded "=> 'SGVsbG8gV29ybGQ=' "
'Hello World' asByteArray base64Encoded. "=>" 'SGVsbG8gV29ybGQ='
</syntaxhighlight>

Latest revision as of 20:10, 12 May 2025

Problem

Encode a String to Base64.

Solution

Convert to ByteArray and then encode using #base64Encoded:

'Hello World' asByteArray base64Encoded.   "=>" 'SGVsbG8gV29ybGQ='