This code works fine for a single charcter:use strict; use warnings; use Tk; use Crypt::CBC; my $plaintext; my $mw = MainWindow->new(); my $password_e = $mw->Entry( -textvariable => \$plaintext, -show => '*', -width => '10' )->pack( -side => 'top'); my $password_b = $mw->Button( -text => "Encrypt", -width => '13', -command => \&encrypt )->pack( -side => 'top', -pady => 10 ); sub encrypt { my $key = pack("H16", "0123456789ABCDEF"); print("$plaintext\n"); my $cipher = Crypt::CBC->new( -cipher => 'DES', -key => $key, ); my $ciphertext = $cipher->encrypt($plaintext); print("$ciphertext\n"); my $recovered = $cipher->decrypt($ciphertext); print("$recovered\n"); } MainLoop
Any idea why?my $plaintext = 'P'; my $key = pack("H16", "0123456789ABCDEF"); print("$plaintext\n"); my $cipher = Crypt::CBC->new( -cipher => 'DES', -key => $key, ); my $ciphertext = $cipher->encrypt($plaintext); print("$ciphertext\n"); my $recovered = $cipher->decrypt($ciphertext); print("$recovered\n");
2006-10-12 Retitled by g0n, as per Monastery guidelines
Original title: 'Tk Error Mystery'
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |