Perl Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Perl Examples

Quick Start
Perl Unicode
Perl Byte Array
Perl Certs
Perl Email
Perl Encryption
Perl FTP
HTML-to-XML
Perl HTTP
Perl IMAP
Perl MHT
Perl MIME
Perl RSA
Perl S/MIME
Perl Signatures
Perl Socket
Perl Spider
Perl Tar
Perl Upload
Perl XML
Perl XMP
Perl Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Re-Encode a String (Hex, Base64, URL, etc)

Demonstrates how to convert from one encoding to another. For example: base64 to hex, URL to base64, base64 to quoted-printable, etc.

Note: The ReEncode method is unreleased at the time of this writing (08-April-2008) The next major Chilkat Crypt2 release after this date will include the ReEncode method.

Chilkat Module for Perl 5.8.*

Chilkat Module for Perl 5.10.*

use chilkat;


$crypt = new chilkat::CkCrypt2();

#  Any string argument automatically begins the 30-day trial.
$success = $crypt->UnlockComponent("30-day trial");
if ($success != 1) {
    print "Crypt component unlock failed" . "\n";
    exit;
}

$hexStr = "41424344E0E1E2E3";

$fromEncoding = "hex";
$toEncoding = "base64";

#  Convert from hex to base64
$base64 = $crypt->reEncode($hexStr,$fromEncoding,$toEncoding);
print $base64 . "\r\n";

#  Now convert from base64 to quoted-printable:
$fromEncoding = "base64";
$toEncoding = "quoted-printable";
$qp = $crypt->reEncode($base64,$fromEncoding,$toEncoding);
print $qp . "\r\n";

#  Now convert from quoted-printable to URL:
$fromEncoding = "quoted-printable";
$toEncoding = "url";
$urlEnc = $crypt->reEncode($qp,$fromEncoding,$toEncoding);
print $urlEnc . "\r\n";

#  Now convert from URL back to hex:
$fromEncoding = "url";
$toEncoding = "hex";
$hexStr = $crypt->reEncode($urlEnc,$fromEncoding,$toEncoding);
print $hexStr . "\r\n";

#  The output of this program is:
#  QUJDRODh4uM=
#  ABCD=E0=E1=E2=E3
#  ABCD%E0%E1%E2%E3
#  41424344E0E1E2E3

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.