Hex
SHA1
MD5
Base64
ASCII
URL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | #!usr/bin/perl #Codificator (C) Doddy Hackman 2011 use Tk; use Digest::MD5; use Digest::SHA1; use MIME::Base64; use URI::Escape; if ($^O eq 'MSWin32') { use Win32::Console; Win32::Console::Free(); } $header= "This tool encode text in : Hex SHA1 MD5 Base64 ASCII URL "; $window = MainWindow->new(-background=>"black",-foreground=>"white"); $window->geometry("500x500+80+80"); $window->title("Codificator (C) Doddy Hackman 2011"); $window->resizable(0,0); $window->Label(-background=>"black",-foreground=>"white",-font=>"Impact",-text=>"Codificator")->pack(); $window->Label(-background=>"black",-foreground=>"white")->pack(); $window->Label(-background=>"black",-foreground=>"white")->pack(); $window->Label(-background=>"black",-foreground=>"white",-text=>"Code")->place(-x =>180, -y => 70); $window->Optionmenu(-background=>"black",-foreground=>"white",-activebackground=>'white', -options => [[HEX=>HEX], [ASCII=>ASCII], [BASE64=>BASE64], [MD5=>MD5],[SHA1=>SHA1],[URL=>URL]], -variable => \$var, -textvariable => \$codificacion )->place(-x =>220, -y => 70); my $rot = $window->Text(-background=>"black",-foreground=>"white",-width=> 45,-height=> 15)->place(-x =>90, -y => 150); $window->Button(-text=>"Encode",-background=>"black",-foreground=>"white",-activebackground=>"white",-command=>\&encode,-width=>"10")->place(-x =>12, -y => 170); $window->Button(-text=>"Decode",-background=>"black",-foreground=>"white",-activebackground=>"white",-command=>\&decode,-width=>"10")->place(-x =>12, -y => 200); $window->Button(-text=>"Clear",-background=>"black",-foreground=>"white",-activebackground=>"white",-command=>\&clear,-width=>"10")->place(-x =>420, -y => 170); $window->Button(-text=>"About",-background=>"black",-foreground=>"white",-activebackground=>"white",-command=>\&about,-width=>"10")->place(-x =>420, -y => 200); $window->Button(-text=>"Exit",-background=>"black",-foreground=>"white",-activebackground=>"white",-command=>[$window=>'destroy'],-width=>"10")->place(-x =>420, -y => 230); $window->Label(-background=>"black",-foreground=>"white",-text=>"Copyright 2011 Doddy Hackman",-font=>"Impact")->place(-x =>150, -y => 430); $rot->insert('end',$header); MainLoop; sub about { my $venta = MainWindow->new(-background=>"black"); $venta->geometry("300x180+20+20"); $venta->title("About"); $venta->resizable(0,0); $venta->Label(-font=>"Impact",-text=>"\nCodificator",-background=>"black",-foreground=>"white")->pack(); $venta->Label(-text=>"\nProgrammer : Doddy Hackman\n\nContact : lepuke[at]hotmail[com]\n\n",-background=>"black",-foreground=>"white")->pack(); $venta->Button(-text=>"Exit",-foreground=>"white",-background=>"black",-command => [$venta => 'destroy'],-activebackground=>'white',-width=>"20")->pack() } sub clear { $rot->delete('0.1','end'); } sub encode { $text = $rot->get("1.0", "end"); chomp $text; &clear; if ($codificacion eq "HEX") { $result = hexar($text); $rot->insert('end',$result); print $result; } elsif ($codificacion eq "SHA1") { $sha1 = Digest::SHA1->new->add($text); my $digest = $sha1->digest; $rot->insert('end',$digest); } elsif ($codificacion eq "BASE64") { $result = encode_base64($text); $rot->insert('end',$result); } elsif ($codificacion eq "URL") { my $codec = Badger::Codec::URL->new(); my $ya = $codec->encode($text); $rot->insert('end',$ya); } elsif ($codificacion eq "ASCII") { $result = ascii($text); $rot->insert('end',$result); } elsif ($codificacion eq "MD5") { $digest = Digest::MD5->md5_hex($text); $rot->insert('end',$digest); } else { $window->messageBox(-message=>"What?!\n"); }} sub decode { $text = $rot->get("1.0", "end"); chomp $text; &clear; if ($codificacion eq "HEX") { $result = decodera($text); $rot->insert('end',$result); } elsif ($codificacion eq "SHA1") { $window->messageBox(-message=>"What?! , it's not possible with a function decoded\n"); } elsif ($codificacion eq "BASE64") { $result = decode_base64($text); $rot->insert('end',$result); } elsif ($codificacion eq "URL") { my $codec = Badger::Codec::URL->new(); my $ya = $codec->decode($text); $rot->insert('end',$ya); } elsif ($codificacion eq "ASCII") { $result = ascii_de($text); $rot->insert('end',$result); } elsif ($codificacion eq "MD5") { $window->messageBox(-message=>"What?! , it's not possible with a function decoded\n"); } else { $window->messageBox(-message=>"What?!\n"); }} sub hexar { my $string = $_[0]; $hex = '0x'; for (split //,$string) { $hex .= sprintf "%x", ord; }return $hex;} sub ascii { return join ',',unpack "U*",$_[0]; } sub decodera { $_[0] =~ s/^0x//; $encode = join q[], map { chr hex } $_[0] =~ /../g; return $encode; } sub ascii_de { $_[0] = join q[], map { chr } split q[,],$_[0]; return $_[0]; } # ¿ The End ? |
0 comentarios: sobre [Perl TK] Codificator
Publicar un comentario para [Perl TK] Codificator