Base64编码互换程序(Tk)

#!/usr/bin/perl
# jondy# http://blog.youkuaiyun.com/jondynet
use MIME::Base64;
use Tk;
use Tk::LabFrame;

my $main = new MainWindow;
$main->title('Base64编码互换程序');
$main->geometry("300x150");

$main->LabFrame(-label => "Main",
   -labelside => 'acrosstop',
   width=>276,
   height=>60)->place(-x=>8,-y=>10);
my $basecode = $main->Entry(-width => 20,
   -relief=>'groove',
   -font=>'{Courier New} 13 {normal}')->place(-x=>20,-y=>35);
my $ascicode = $main->Entry(-width => 20,
   -relief=>'groove',
   -font=>'{Courier New} 13 {normal}')->place(-x=>20,-y=>60);
$main->Button(-text => '转 换',
   -relief=>'groove',
   -font=>'{宋体} 9 {normal}',
   -command=>/&encode)->place(-x=>235,-y=>34);
$main->Button(-text => '还 原',
   -relief=>'groove',
   -height=>'0',
   -font=>'{宋体} 9 {normal}',
   -command=>/&decode)->place(-x=>235,-y=>59);
$main->Label(-text => 'Base64编码转换程序',
   -font=>'{宋体} 9 {normal}',
   -width=>30)->place(-x=>128,-y=>105);
$main->Label(-text => "Powered by jondy /n jondy/@tom.com",
   -font=>'{宋体} 9 {normal}',
   -width=>30)->place(-x=>128,-y=>120);

$basecode -> insert('0','BASE64');
$ascicode -> insert('0','ASCII');

MainLoop;

sub encode{
 my $asci2code = $basecode->get;
 $asci2code = decode_base64($asci2code);
 $ascicode -> delete('0','end');
 $ascicode -> insert('0',$asci2code);
}

sub decode{
 my $base64code = $ascicode->get;
 $base64code = encode_base64($base64code);
 chop($base64code);
 $basecode -> delete('0','end');
 $basecode -> insert('0',$base64code);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值