- SEE ALSO
- COPYRIGHT AND LICENSE
Crypt::XTEA - Implementation of the eXtended Tiny Encryption Algorithm
use Crypt::XTEA; use Crypt::CBC; my $xtea = Crypt::XTEA->new( $key ); my $cbc = Crypt::CBC->new( -cipher => $xtea ); my $text = 'The quick brown fox jumps over the lazy dog.'; my $cipher_text = $cbc->encrypt( $text ); my $plain_text = $cbc->decrypt( $cipher_text );
In cryptography, XTEA (eXtended TEA) is a block cipher designed to correct weaknesses in TEA. The cipher's designers were David Wheeler and Roger Needham of the Cambridge Computer Laboratory, and the algorithm was presented in an unpublished technical report in 1997 (Needham and Wheeler, 1997). It is not subject to any patents.
Like TEA, XTEA is a 64-bit block Feistel cipher with a 128-bit key and a suggested 64 Feistel rounds (i.e 32 cycles). Crypt::XTEA uses the recommended value of 32 cycles by default.
This module implements XTEA encryption. It supports the Crypt::CBC interface, with the following functions.
Returns the maximum XTEA key size, 16 bytes.
Returns the XTEA block size, which is 8 bytes. This function exists so that Crypt::XTEA can work with Crypt::CBC.
my $xtea = Crypt::XTEA->new( $key, $rounds, little_endian => 0 );
This creates a new Crypt::XTEA object with the specified key. The optional rounds parameter specifies the number of rounds of encryption to perform, and defaults to 32. If the key is provided as a scalar string, it is split to a series of 4x big-endian 32-bit integers. If little-endian order is required instead, the optional little_endian key can be set to 1. This will also cause all blocks to be interpreted as 2x little-endian 32-bit integers.
$cipher_text = $xtea->encrypt($plain_text);
Encrypts blocksize() bytes of $plain_text and returns the corresponding ciphertext.
$plain_text = $xtea->decrypt($cipher_text);
Decrypts blocksize() bytes of $cipher_text and returns the corresponding plaintext.
Kars Wang <firstname.lastname@example.org>
This software is copyright (c) 2016 by Kars Wang.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.