#!/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