use warnings;
use strict;
use Math::Random::ISAAC;

my $message = "a Top Secret secret";
my $key = "this is my secret key";

my $enc = xor_isaac($key, $message);
my $dec = xor_isaac($key, join "", pack "H*", $enc);

print "Message: $message\n";
print "Key   : $key\n";
print "XOR   : $enc\n";
print "XOR dcr: ", join("", pack "H*", $dec), "\n";

sub xor_isaac {
  my($key, $msg) = @_;

  
  my $rng = Math::Random::ISAAC->new( map { ord } split "",$key );

  
  my @iranda = map { $_ % 95 + 32 }  
               reverse               
               map { $rng->irand }   
               0..255;               
  
  join "", map { sprintf "%02X",$_ }         
           map { ord($_) ^ shift(@iranda) }  
           split "", $msg;                   
}