NAME
Crypt::XXTEA - XXTEA encryption arithmetic module.
SYNOPSIS
use Crypt::XXTEA;
DESCRIPTION
XXTEA is a secure and fast encryption algorithm. It's suitable for web development. This module allows you to encrypt or decrypt a string using the algorithm.
FUNCTIONS
- xxtea_encrypt
-
my $ciphertext = xxtea_encrypt($plaintext, $key);
This function encrypts $plaintext using $key and returns the $ciphertext.
- encrypt
-
my $ciphertext = Crypt::XXTEA::encrypt($plaintext, $key);
This function is the same as xxtea_encrypt.
- xxtea_decrypt
-
my $plaintext = xxtea_decrypt($ciphertext, $key);
This function decrypts $ciphertext using $key and returns the $plaintext.
- decrypt
-
my $plaintext = Crypt::XXTEA::decrypt($ciphertext, $key);
This function is the same as xxtea_decrypt.
EXAMPLE
use Crypt::XXTEA;
my $ciphertext = xxtea_encrypt("Hello XXTEA.", "1234567890abcdef");
my $plaintext = xxtea_decrypt($ciphertext, "1234567890abcdef");
print $plaintext;
$ciphertext = Crypt::XXTEA::encrypt("Hi XXTEA.", "1234567890abcdef");
$plaintext = Crypt::XXTEA::decrypt($ciphertext, "1234567890abcdef");
print $plaintext;
NOTES
If $plaintext is equal to "", it returns "".
It returns 0 when fails to decrypt.
Only the first 16 bytes of $key is used. if $key is shorter than 16 bytes, it will be padding \0.
The XXTEA algorithm is stronger and faster than Crypt::DES, Crypt::Blowfish & Crypt::IDEA.
SEE ALSO
Crypt::DES Crypt::Blowfish Crypt::IDEA
COPYRIGHT
The implementation of the XXTEA algorithm was developed by, and is copyright of, Ma Bingyao (andot@ujn.edu.cn).