1#!/usr/local/bin/perl
2
3use diagnostics;
4use strict;
5use warnings;
6use Crypt::Rabbit;
7
8my $key = pack "H32", "00112233445566778899aabbccddeeff";
9my $cipher = new Crypt::Rabbit $key;
10
11my $ks = $cipher->keysize;
12print "keysize = $ks bytes\n";
13
14print "Encrypting...\n\n";
15my $plaintext1 = pack "H40", "00112233445566778899aabbccddeeff01234567";
16print "plaintext1  : ", unpack("H*", $plaintext1), "\n";
17
18my $ciphertext1 = $cipher->encrypt($plaintext1);
19print "ciphertext1 : ", unpack("H*", $ciphertext1), "\n";
20
21my $plaintext2 = pack "H60", 0;
22print "plaintext2  : ", unpack("H*", $plaintext2), "\n";
23
24my $ciphertext2 = $cipher->encrypt($plaintext2);
25print "ciphertext2 : ", unpack("H*", $ciphertext2), "\n";
26
27my $plaintext3 = pack "H32", "00112233445566778899aabbccddeeff";
28print "plaintext3  : ", unpack("H*", $plaintext3), "\n";
29
30my $ciphertext3 = $cipher->encrypt($plaintext3);
31print "ciphertext3 : ", unpack("H*", $ciphertext3), "\n";
32
33print "\nDecrypting...\n\n";
34
35my $key2 = pack "H32", "00112233445566778899aabbccddeeff";
36my $cipher2 = new Crypt::Rabbit $key2;
37
38$plaintext1 = $cipher2->decrypt($ciphertext1);
39print "plaintext1  : ", unpack("H*", $plaintext1), "\n";
40
41$plaintext2 = $cipher2->decrypt($ciphertext2);
42print "plaintext2  : ", unpack("H*", $plaintext2), "\n";
43
44$plaintext3 = $cipher2->decrypt($ciphertext3);
45print "plaintext3  : ", unpack("H*", $plaintext3), "\n";
46
47print "\n";
48
49