#!/usr/bin/perl -w use strict; use Crypt::DES; my $key = pack("H16", "hello"); my $cipher = new Crypt::DES $key; for (my $i=1;$i<11;$i++){ my $ciphertext = $cipher->encrypt(&pad($i)); print "ciphertext: ".unpack("H16", $ciphertext); print " plaintext : ".$cipher->decrypt($ciphertext)."\n"; } sub pad { my $padstr = shift; my $padlen = length($padstr); for (my $i=$padlen;$i<8;$i++) { $padstr = '#'.$padstr; } return $padstr; } #### ciphertext: b9f13b4dadafc8a7 plaintext : #######1 ciphertext: a63ce27095356ceb plaintext : #######2 ciphertext: df037bd297aa73af plaintext : #######3 ciphertext: 0eaf7e009f26dc71 plaintext : #######4 ciphertext: 878da30ec4b03db2 plaintext : #######5 ciphertext: 38bb5f88a797e62e plaintext : #######6 ciphertext: e001696d8bcec155 plaintext : #######7 ciphertext: 6c3446a5cf32e3f2 plaintext : #######8 ciphertext: 21b4798bb48eb72d plaintext : #######9 ciphertext: 8ff59b7237d31c90 plaintext : ######10