The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Crypt::OTP - Perl implementation of the One Time Pad (hence, OTP) encryption method.

SYNOPSIS

  use Crypt::OTP;
  $cipher = Crypt::OTP( $pad, $message );
        or
  $cipher = Crypt::OTP( $pad, $message, $mode );

DESCRIPTION

The One Time Pad encryption method is very simple, and impossible to crack without the actual pad file against which the to-be-encrypted message is XOR'ed. Encryption and decryption are performed using excactly the same method, and the message will decrypt correctly only if the same pad is used in decryption as was use in encryption.

The safest method of use is to use a large, semi-random text file as the pad, like so:

$ciphertext = OTP( "my_pad.txt", $message );

However, I've also implemented a second method which does not rely on an external pad file, though this mathod is substantially less secure.

$less_secure = OTP( "This text takes the place of my pad file", $message, 1 );

In this example, the "1" instructs the OTP sub-routine to use the contents of the first element as the pad, rather than the default method which is to use the first element as the name of the external pad file.

If the file specified using the first method does not exist, OTP returns zero. In all other cases, OTP returns the XOR'ed message.

AUTHOR

Kurt Kincaid, sifukurt@yahoo.com

SEE ALSO

perl(1).