Crypt::OTP26

Crypt::OTP26 is a classic form of encryption.
Download

Crypt::OTP26 Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • osfameron
  • Publisher web site:
  • http://search.cpan.org/~osfameron/Crypt-OTP26-0.02/lib/Crypt/OTP26.pm

Crypt::OTP26 Tags


Crypt::OTP26 Description

Crypt::OTP26 is a classic form of encryption. Crypt::OTP26 is a classic form of encryption.This implements a mod-26 One Time Pad encryption, similar to the sort classically used with pen and paper, as described in http://en.wikipedia.org/wiki/One_time_padIts primary use is to explore the intriguing situation detailed at http://itre.cis.upenn.edu/~myl/languagelog/archives/003314.htmlNB: We don't handle the cases of generating or securely transmitting the pads themselves.Also, only lower case alpha (ascii 'a-z') characters are handled. If you are actually encrypting and transmitting useful and valuable data, you should use a proper strong crypto module.And though it's based on the OneTimePad concept, it actually supports the pad being shorter or longer than the encrypted text, in which case it is truncated or repeated as appropriate. So... don't do that!METHODSnew my $otp = Crypt::OTP26->new();cryptEncrypts an alpha text (a-z) with an alpha pad (a-z), by performing mod26 addition on it. my $encrypted = $otp->crypt( $pad, $text ); # though it's commutative, so can be in either order my $encrypted = $otp->crypt( 'aced', 'scam' ); # returns 'seep'decryptDecrpyts a previously encrypted text using mod26 sutraction. my $encrypted = $otp->decrypt( $crypt, $pad ); my $encrypted = $otp->decrypt( 'aced', 'seep' ); # returns 'scam'char2intReturn the mod26 integer value of an ascii character. my $int = $otp->char2int('a'); # returns 0int2char my $char = $otp->int2char( 1 ); # returns 'b'Will always return 'a'-'z'crypt_char my $char = $otp->crypt_char( 'a', 's' ); # returns 's'Crypts 2 characters by performing mod26 addition on them. Called internally by crypt above.decrypt_charDecrypts the character with the appropriate letter from the pad, by performing mod26 subtraction. Called internally decrypt above. my $char = $otp->decrypt_char( $crypt_char, $pad_char ); my $char = $otp->decrypt_char( 't', 's' ); # returns 'b'mk_streamPrivate method for iterating the pad and the string. Requirements: · Perl


Crypt::OTP26 Related Software