#
# Hello World Program in Perl
#
print "\nHello World!\n";

use Digest::MD5;
use MIME::Base64;
use strict;

my $cipher = "OTQadxNUCCBxMjhFQkZFRDBBRkYzNUExOUFCMTVCOTMyNg==";
my $secret = "GXiLFsiF7mKwXchjFF";

my ($salt, $xor) = unpack('a2 a*', MIME::Base64::decode_base64($cipher));

my $hash = Digest::MD5::md5($salt . $secret);
# Replicate the hash until its same length as the xored cipher
# which should be a multiple of 16 bytes
my $hashrep = $hash x int((length($xor) + 15) / 16);
my $plaintext = $xor ^ $hashrep;
# Strip off any NUL padding
$plaintext =~ s/\000*$//;
    
print $salt; 
print "\n";
print $xor;
print "\n";
print $plaintext;
print "\n";