if you absolutely need to use -textvariable, you need to pad#!/usr/bin/perl 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 { $plaintext = $password_e->get(); my $key = pack("H16", "0123456789ABCDEF"); print "text->$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
#!/usr/bin/perl 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 "text->$plaintext\n"; #this will allow you to use -textvariable $plaintext = "\0" x ( 8 - length($plaintext)%8 ) . $plaintext; 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
In reply to Re: Strange Error from interaction of Tk and Crypt::CBC
by zentara
in thread Strange Error from interaction of Tk and Crypt::CBC
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |