in reply to Non-ASCii character encryption

Make sure you open the files using binmode.

open(my $fh, '<', 'file') or die("open \"file\": $!\n"); binmode($fh);

If you want encryption, you should really uses Rijndael aka AES (or Twofish or Blowfish) via Crypt::CBC.