Sample code for 30+ languages & platforms
Perl

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat Perl Downloads

Perl
use chilkat();

$success = 0;

$bd = chilkat::CkBinData->new();

$s = "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump";

$success = $bd->AppendString($s,"utf-8");

$strBase64 = $bd->getEncoded("base64");
print $strBase64 . "\r\n";

# To decode:
$bd2 = chilkat::CkBinData->new();
$bd2->AppendEncoded($strBase64,"base64");

$decoded = $bd2->getString("utf-8");
print $decoded . "\r\n";