Crypt-TC18
view release on metacpan or search on metacpan
sub keysize { 8 }
sub blocksize { 16 }
sub rounds { 16 } # may be useful in some applications
1;
__END__
=head1 NAME
Crypt::TC18 - Crypt::CBC compliant block cipher
=head1 ABSTRACT
B<TC18> is 128-bit block cipher that accepts a 64-bit key. TC18 is also
known as B<XSM>.
=head1 SYNOPSIS
use Crypt::TC18;
$bs = $cipher->blocksize;
$ks = $cipher->keysize;
$r = $cipher->rounds;
=head1 DESCRIPTION
TC18 is 128-bit block cipher that accepts a 64-bit key. It was
designed by Tom St. Denis.
This module supports the Crypt::CBC interface, with the following
functions.
=head2 Functions
=over
=item B<blocksize>
Returns the size (in bytes) of the block (16, in this case)
examples/cbc-mode view on Meta::CPAN
#!/usr/local/bin/perl
use diagnostics;
use strict;
use warnings;
use Crypt::CBC; # CBC automatically loads TC18 for us
my $key = pack "H16", "0001020304050607";
my $IV = pack "H32", "0123456789abcdef0123456789abcdef";
my $cipher = Crypt::CBC->new({'key' => $key,
'cipher' => 'TC18',
'iv' => $IV,
'regenerate_key' => 1,
'padding' => 'standard',
'prepend_iv' => 0
});
my $plaintext1 = pack "H32", "000102030405060708090a0b0c0d0e0f";
print "plaintext1 : ", unpack("H*", $plaintext1), "\n";
examples/fileenc view on Meta::CPAN
#!/usr/local/bin/perl
use diagnostics;
use strict;
use warnings;
use Getopt::Long;
use Crypt::CBC;
my $SRC_RAND = "/dev/urandom";
my ($encrypt, $decrypt, $help, $cipher, $blocksize);
GetOptions("encrypt" => \$encrypt, "decrypt" => \$decrypt,
"cipher=s" => \$cipher, "blocksize=i" => \$blocksize,
"help" => \$help);
sub syntax
examples/fileenc view on Meta::CPAN
if ($encrypt) {
open RANDSRC, $SRC_RAND;
read RANDSRC, $IV, $blocksize; # generate one-time, random IV
close RANDSRC;
print $IV; # make IV as 1st ciphertext block
} elsif ($decrypt) {
read INFILE, $IV, $blocksize;
}
my $obj = Crypt::CBC->new({'key' => $key,
'cipher' => $cipher,
'iv' => $IV,
'regenerate_key' => 1,
'padding' => 'standard',
'prepend_iv' => 0
});
#$obj->start('encrypt') if ($encrypt);
#$obj->start('decrypt') if ($decrypt);
examples/pin-generator view on Meta::CPAN
#!/usr/local/bin/perl
use diagnostics;
use strict;
use warnings;
use Crypt::CBC;
use MIME::Base64;
sub get_input
{
my ($message) = @_;
local $| = 1;
local *TTY;
open TTY,"/dev/tty";
my ($tkey1, $tkey2);
system "stty -echo </dev/tty";
examples/pin-generator view on Meta::CPAN
} until $tkey1 eq $tkey2;
system "stty echo </dev/tty";
close TTY;
return $tkey1;
}
my $key = &get_input("username");
my $IV = pack "H32", "0123456789abcdef0123456789abcdef";
my $cipher = Crypt::CBC->new({'key' => $key,
'cipher' => 'TC18',
'iv' => $IV,
'regenerate_key' => 1,
'padding' => 'standard',
'prepend_iv' => 0
});
my $ciphertext = $cipher->encrypt($key);
print "Your password is\n", encode_base64($ciphertext, ""), "\n";
( run in 0.617 second using v1.01-cache-2.11-cpan-e1769b4cff6 )