Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

CryptoPad v2.00

by sifukurt (Hermit)
on Nov 29, 2002 at 17:21 UTC ( #216561=sourcecode: print w/replies, xml ) Need Help??
Category: Cryptography
Author/Contact Info Kurt Kincaid (sifukurt@yahoo.com)
Description: Here's the latest incarnation of CryptoPad. I've added two more encryption algorithms and moved the algorithms to a drop-down list, rather than each one having a separate button. Hopefully you'll find it useful. As always, constructive comments are welcome.
#--------------------------------------------------------------------#
# CryptoPad
#       Date Written:   07-Nov-2001 09:29:47 AM
#       Last Modified:  29-Nov-2002 10:03:08 AM
#       Author:    Kurt Kincaid (sifukurt@yahoo.com)
#       Copyright (c) 2002, Kurt Kincaid
#           All Rights Reserved
#
# NOTICE: This package is free software and may be modified and/or
#         redistributed under the same terms as Perl itself.
#--------------------------------------------------------------------#

use Tk;
use Tk::Dialog;
use Tk::DialogBox;
use Tk::Text;
use Tk::FileSelect;
use Tk::FileDialog;
use Tk::Menu;
use Tk::Menubutton;
use Tk::widgets qw(Menu);
use Tk::Checkbutton;
use File::Butler;
use File::Glob;
use Crypt::RC4;
use Crypt::GOST_PP;
use Crypt::TripleDES;
use Crypt::CBC;
use Crypt::Rijndael_PP ':all';
use Crypt::RIPEMD160;
use Crypt::PPDES;
use Crypt::RC5;
use Crypt::CBC;
use Crypt::CAST5_PP;
use URI::Escape;
use Digest::MD2;
use Digest::MD4;
use Digest::MD5;
use Digest::SHA1;
use constant;
use strict;
use vars qw/ $temp_var $cipher $info $t $title $enc_type $mw $passphra
+se
  $ref $algorithm $f $fileName $ea $help $saveas $des $aes $hex
  $hex2 $hex3 $hex4 $hex5 $tripledes_header $tripledes_footer
  $rc4_header $rc4_footer $rc5_header $rc5_footer $cast5_header
  $cast5_footer $gost_header $gost_footer $m $fname $mod_date $FSref
  $ripemd $aes_header $aes_footer $VERSION $mm $tt $md2 $md4 $md5
  $helptext $help_label $error @lines $sha /;

$VERSION          = "2.00";
$mod_date         = "29-Nov-2002 10:03:08 AM";
$title            = "CryptoPad v" . $VERSION;
$rc4_header       = "----- CryptoPad RC4 Encrypted Message: Begin ----
+-\n";
$rc4_footer       = "\n----- CryptoPad RC4 Encrypted Message: End ----
+-";
$tripledes_header = "----- CryptoPad TripleDES Encrypted Message: Begi
+n -----\n";
$tripledes_footer = "\n----- CryptoPad TripleDES Encrypted Message: En
+d -----";
$aes_header       = "----- CryptoPad AES (Rijndael) Encrypted Message:
+ Begin -----\n";
$aes_footer       = "\n----- CryptoPad AES (Rijndael) Encrypted Messag
+e: End -----";
$gost_header      = "----- CryptoPad GOST Encrypted Message: Begin ---
+--\n";
$gost_footer      = "\n----- CryptoPad GOST Encrypted Message: End ---
+--";
$rc5_header       = "----- CryptoPad RC5 Encrypted Message: Begin ----
+-\n";
$rc5_footer       = "\n----- CryptoPad RC5 Encrypted Message: End ----
+-";
$cast5_header     = "----- CryptoPad CAST5 Encrypted Message: Begin --
+---\n";
$cast5_footer     = "\n----- CryptoPad CAST5 Encrypted Message: End --
+---";

$mw = MainWindow->new;
$mw->title( $title );

$m = $mw->Frame( -relief => 'groove', -bd => 2 )->pack( -side => 'top'
+, -anchor => 'n', -fill => 'x' );

$m->Menubutton(
    -text      => "File",
    -tearoff   => 0,
    -menuitems => [
        [
            "command" => "New",
            -command  => \&clear
        ],
        [
            "command" => "Open",
            -command  => \&OpenDocument
        ],
        [
            "command" => "Save",
            -command  => \&SaveDocument
        ],
        [
            "command" => "Save As",
            -command  => \&SaveAs
        ],
        [
            "command" => "Exit",
            -command => sub { exit }
        ]
    ]
)->pack( -side => 'left' );

$m->Menubutton(
    -text      => "Help",
    -tearoff   => 0,
    -menuitems => [
        [
            "command" => "Help...",
            -command  => \&help
        ],
        [
            "command" => "About...",
            -command  => \&about
        ]
    ]
)->pack( -side => 'left' );

$f = $mw->Frame->pack( -side => 'top', -fill => 'x' );

$ea = "ENCRYPTION ALGORITHM:";
$f->Menubutton(
    -text      => "Choose Algorithm",
    -relief    => 'raised',
    -tearoff   => 0,
    -menuitems => [
        [
            "command" => "AES",
            -command => sub { $algorithm = "$ea AES"; $enc_type = "aes
+"; }
        ],
        [
            "command" => "TripleDES",
            -command => sub { $algorithm = "$ea TripleDES"; $enc_type 
+= "tripledes"; }
        ],
        [
            "command" => "GOST",
            -command => sub { $algorithm = "$ea GOST"; $enc_type = "go
+st"; }
        ],
        [
            "command" => "RC4",
            -command => sub { $algorithm = "$ea RC4"; $enc_type = "rc4
+"; }
        ],
        [
            "command" => "RC5",
            -command => sub { $algorithm = "$ea RC5"; $enc_type = "rc5
+"; }
        ],
        [
            "command" => "CAST5",
            -command => sub { $algorithm = "$ea CAST5"; $enc_type = "c
+ast5"; }
        ]
    ]
)->pack( -side => 'left' );

$f->Label( -text => "Passphrase:" )->pack( -side => 'left', -anchor =>
+ 'w' );
$f->Entry( -show => '*', -textvariable => \$passphrase )->pack(
    -side   => 'left',
    -anchor => 'w',
    -fill   => 'x',
    -expand => 1
);

$f->Button( -text => "Message Digest", -command => \&Digest )->pack( -
+side  => 'right' );
$f->Button( -text => "Decrypt",        -command => \&decrypt )->pack( 
+-side => 'right', -anchor => 'e' );
$f->Button( -text => "Encrypt",        -command => \&encrypt )->pack( 
+-side => 'right', -anchor => 'e' );

if ( $algorithm eq "" ) {
    $algorithm = "No Encryption Algorithm Selected";
}

$f->Button( -text => "Clear", -command => \&clear )->pack( -side => 'r
+ight', -anchor => 'e' );

$mw->Label( -textvariable => \$algorithm, -relief => 'ridge' )->pack( 
+-side => 'top', -fill => 'x' );

$mw->Label( -textvariable => \$info, -relief => 'ridge' )->pack( -side
+ => 'bottom', -fill => 'x' );
$t = $mw->Scrolled( "Text", -wrap => 'word', -scrollbars => 'e' )->pac
+k(
    -side   => 'bottom',
    -fill   => 'both',
    -expand => 1
);

$info = $title;

MainLoop;

#--------------------------------------------------------------------#
# Encryption Sub-Routines
#--------------------------------------------------------------------#

sub encrypt {
    if ( $enc_type eq "aes" ) {
        aes_encrypt();
    } elsif ( $enc_type eq "tripledes" ) {
        tripledes_encrypt();
    } elsif ( $enc_type eq "gost" ) {
        gost_encrypt();
    } elsif ( $enc_type eq "rc4" ) {
        rc4_encrypt();
    } elsif ( $enc_type eq "rc5" ) {
        rc5_encrypt();
    } elsif ( $enc_type eq "cast5" ) {
        cast5_encrypt();
    } elsif ( $enc_type eq "" ) {
        Error( "Error", "No encryption algorithm has been selected. Pl
+ease select an algorithm and try again." );
    }
}

sub decrypt {
    if ( $enc_type eq "aes" ) {
        aes_decrypt();
    } elsif ( $enc_type eq "tripledes" ) {
        tripledes_decrypt();
    } elsif ( $enc_type eq "gost" ) {
        gost_decrypt();
    } elsif ( $enc_type eq "rc4" ) {
        rc4_decrypt();
    } elsif ( $enc_type eq "rc5" ) {
        rc5_decrypt();
    } elsif ( $enc_type eq "cast5" ) {
        cast5_decrypt();
    } elsif ( $enc_type eq "" ) {
        Error( "Error", "No encryption algorithm has been selected. Pl
+ease select an algorithm and try again." );
    }
}

sub rc4_encrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $cipher = RC4( $passphrase, $temp_var );
        $info = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $rc4_header . $cipher . $rc4_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub rc4_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $temp_var =~ s/$rc4_header//;
        $temp_var =~ s/$rc4_footer//;
        $temp_var =~ s/\n//g;
        $temp_var = uri_unescape( $temp_var );
        $cipher = RC4( $passphrase, $temp_var );
        chomp $cipher;
        $info = "";
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub rc5_encrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        my $ref = Crypt::RC5->new( $passphrase, 16 );
        $cipher = $ref->encrypt( $temp_var );
        $info   = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $rc5_header . $cipher . $rc5_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub rc5_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $temp_var =~ s/$rc5_header//;
        $temp_var =~ s/$rc5_footer//;
        $temp_var =~ s/\n//g;
        $temp_var = uri_unescape( $temp_var );
        my $ref = Crypt::RC5->new( $passphrase, 16 );
        $cipher = $ref->decrypt( $temp_var );
        chomp $cipher;
        $info = "";
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub cast5_encrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        my $ref = Crypt::CBC->new(
            {
                key    => $passphrase,
                cipher => "CAST5_PP",
            }
        );
        $cipher = $ref->encrypt( $temp_var );
        $info   = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $cast5_header . $cipher . $cast5_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub cast5_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $temp_var =~ s/$cast5_header//;
        $temp_var =~ s/$cast5_footer//;
        $temp_var =~ s/\n//g;
        $temp_var = uri_unescape( $temp_var );
        my $ref = Crypt::CBC->new(
            {
                key    => $passphrase,
                cipher => "CAST5_PP",
            }
        );
        $cipher = $ref->decrypt( $temp_var );
        chomp $cipher;
        $info = "";
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub tripledes_encrypt {
    $info = "Processing....";
    my $des = new Crypt::TripleDES;
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $cipher = $des->encrypt3( $temp_var, $passphrase );
        $info = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $tripledes_header . $cipher . $tripledes_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub tripledes_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        my $des = new Crypt::TripleDES;
        $temp_var =~ s/$tripledes_header//;
        $temp_var =~ s/$tripledes_footer//;
        $temp_var =~ s/\n//g;
        $temp_var = uri_unescape( $temp_var );
        $cipher = $des->decrypt3( $temp_var, $passphrase );
        $cipher =~ s/\s*$//;
        chomp $cipher;
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub aes_encrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $aes = new Crypt::CBC( $passphrase, 'Rijndael_PP' );
        $cipher = $aes->encrypt( $temp_var );
        $info   = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $aes_header . $cipher . $aes_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub aes_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        @lines = split ( /\n/, $temp_var );
        shift @lines;
        pop @lines;
        $temp_var = join ( "", @lines );
        $temp_var = uri_unescape( $temp_var );
        $aes      = new Crypt::CBC( $passphrase, 'Rijndael_PP' );
        $cipher   = $aes->decrypt( $temp_var );
        chomp $cipher;
        $info = "";
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub gost_encrypt {
    $info = "Processing....";
    my $ref = Crypt::GOST_PP->new( $passphrase );
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        $cipher = $ref->encrypt( $temp_var );
        $info   = "";
        $t->delete( "1.0", "end" );
        $cipher = uri_escape( $cipher );
        $cipher =~ s/.{80}/$&\n/g;
        chomp $cipher;
        $cipher = $gost_header . $cipher . $gost_footer;
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

sub gost_decrypt {
    $info = "Processing....";
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( Confirm() ) {
        my $ref = Crypt::GOST_PP->new( $passphrase );
        $temp_var =~ s/$gost_header//;
        $temp_var =~ s/$gost_footer//;
        $temp_var =~ s/\n//g;
        $temp_var = uri_unescape( $temp_var );
        $cipher   = $ref->decrypt( $temp_var );
        $cipher =~ s/\s*$//;
        chomp $cipher;
        $t->delete( "1.0", "end" );
        $t->insert( "end", $cipher );
        $info = $title;
    }
}

#--------------------------------------------------------------------#
# End Encryption Sub-Routines
#--------------------------------------------------------------------#

sub clear {
    $t->delete( "1.0", "end" );
    $passphrase = "";
    $info       = $title;
    $algorithm  = "No Encryption Algorithm Selected";
    $enc_type   = "";
}

sub about {
    $mw->Dialog(
        -title => "About...",
        -text  => <<"END", -popover => $mw, -font => 'ansi' )->Show;
$title

Last Modified: $mod_date

Copyright 2002 Kurt Kincaid. All rights reserved.

CryptoPad is free software; you can redistribute it and/or modify it u
+nder the same terms as Perl itself.
END
}

sub Digest {
    $info     = "Generating Message Digest....";
    $hex      = Digest::MD5->new();
    $temp_var = $t->get( "1.0", "end" );
    chomp $temp_var;
    if ( $temp_var eq "" ) {
        $info = $title;
        return;
    }
    $hex->add( $temp_var );
    $md5  = $hex->hexdigest();
    $hex2 = Digest::SHA1->new();
    $hex2->add( $temp_var );
    $sha  = $hex2->hexdigest();
    $hex3 = Digest::MD4->new();
    $hex3->add( $temp_var );
    $md4  = $hex3->hexdigest();
    $hex4 = Digest::MD2->new();
    $hex4->add( $temp_var );
    $md2  = $hex4->hexdigest();
    $hex5 = Crypt::RIPEMD160->new();
    $hex5->reset();
    $hex5->add( $temp_var );
    $ripemd = $hex5->hexdigest();
    $mw->Dialog(
        -title => "Message Digest",
        -text  => <<"END", -popover => $mw, -font => 'ansi' )->Show;
[ SHA ]
$sha

[ MD5 ]
$md5

[ MD4 ]
$md4

[ MD2 ]
$md2

[ RIPEMD-160 ]
$ripemd
    
END
    $info = $title;
}

sub OpenDocument {
    $FSref    = $mw->FileSelect();
    $fileName = $FSref->Show();
    $temp_var = Butler( $fileName, "read" );
    if ( !-e $fileName ) {
        $info = "Cannot open $fileName: $!";
        return;
    }
    $t->delete( "1.0", "end" );
    $t->insert( "end", $temp_var );
}

sub SaveDocument {
    if ( $fileName eq "" ) {
        $saveas = $mw->FileDialog( -Title => 'Save As', -Create => 1 )
+;
        $saveas->Label( -text  => "File Name: ", -relief       => 'gro
+ove' );
        $saveas->Entry( -width => 20,            -textvariable => \$fi
+leName );
        $fname = $saveas->Show();
    }
    $saveas->destroy();
    $temp_var = $t->get( "1.0", "end" );
    Butler( $fname, "write", \$temp_var );
    $info = "$fname saved";
}

sub SaveAs {
    undef $fileName;
    SaveDocument();
}

sub help {
    $helptext = "
$title
    
Last Modified: $mod_date

The encryption is accomplished with your choice of several encryption 
+algorithms, TripleDES (the previous, interim NIST Data Encryption Sta
+ndard), AES (also known as Advanced Encryption Standard, or Rijndael,
+ after the authors, Vincent Rijmen and Joan Daemen, the current NIST 
+Data Encryption Standard), GOST (a 64-bit block cipher with a 256-bit
+ key, which was the encryption standard in the former Soviet Union) R
+C5, a fast block cipher by RSA Security Inc., RC4, which is a symmetr
+ical stream cipher by RSA Security Inc, and the CAST5 block cipher, a
+lso known as CAST-128. It should be noted that to avoid complications
+ with displaying meta-characters, the encyrpted output is escaped via
+ URI::Escape.

CryptoPad supports multiple rounds of encryption. For example, it is p
+ossible to encrypt your data with TripleDES, then with AES, then with
+ RC4. Decryption would then be possible in the reverse order. The nam
+e of the encryption algorithm is shown to facilitate this. It is impo
+rtant to note that knowing which encryption algorithm was used in no 
+way diminishes the security of the encryption.

The Message Digests are generated with SHA1, MD5, MD4, and MD2 Message
+ Digest algorithms by RSA Security Inc., and RIPEMD-160 by Hans Dobbe
+rtin, Antoon Bosselaers, and Bart Preneel, of Katholieke Universiteit
+ Leuven. A Message Digest (also known as \"fingerprint\") is a one-wa
+y encrypted hash function based on the content of the document. It is
+ mathematically infeasible to have two documents with the same Messag
+e Digest, and even less likely that the document would say what you w
+ant it to say. As such, a Message Digest can be used to \"sign\" a do
+cument and verify that the contents of the document have not been alt
+ered, either by accident or design.
";

    $help_label = "$title Help";
    $help       = MainWindow->new();
    $help->title( "Help" );
    $mm = $help->Frame->pack( -side => 'top', -fill => 'x' );
    $mm->Button( -text => "Close Window", -command => sub { $help->des
+troy() } )->pack( -side => 'right' );
    $help->Label( -textvariable => \$help_label, -relief => 'ridge' )-
+>pack( -side => 'bottom', -fill => 'x' );
    $tt = $help->Scrolled(
        "Text",
        -width      => 120,
        -wrap       => 'word',
        -background => '#ffff88',
        -font       => 'ansi',
        -scrollbars => 'e'
    )->pack( -side => 'bottom', -fill => 'both', -expand => 1 );
    $tt->insert( "end", $helptext );
}

sub Confirm {
    if ( $temp_var eq "" ) {
        return 0;
    }
    if ( length( $passphrase ) < 5 ) {
        Error( "Passphrase Error", "The passphrase must be at least 5 
+characters" );
        return 0;
    }
    return 1;
}

sub Error {
    my $error;
    my( $et, $em ) = @_;
    $error = $mw->Dialog(
        -bitmap => 'error',
        -title  => $et,
        -text   => <<"END", -popover => $mw, -font => 'ansi' )->Show;
$em
END
    $info = $title;
}
Replies are listed 'Best First'.
•Re: CryptoPad v2.00
by merlyn (Sage) on Nov 29, 2002 at 21:22 UTC
    From a code-review standpoint:
    • There's far too much cut-n-paste-n-slightly-modified code in this program. Any time the same sequence of three or four lines of code appears amidst some other code that varies only slightly, it should be a big warning sign. For example, suppose you wanted to change "Processing..." to "Working...". You'd have to edit that in half a dozen places. Factor it out!
    • Your chain of "if"-tests should be replaced by a simple hash pointing at the right subroutine to call. That strategy would probably help in the rest as well.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Cryptopad 3.10
by sifukurt (Hermit) on Oct 01, 2003 at 01:59 UTC
    A number of the folks I work with have been using Cryptopad for a while now. I hadn't messed with the code in quite a while, so I figured I'd clean things up a bit, add a few more algorithms, etc., etc. At any rate, here it is...hopefully you'll find it useful. I'd appreciate it any constructive comments.
    #--------------------------------------------------------------------# # CryptoPad # Date Written: 07-Nov-2001 09:29:47 AM # Last Modified: 30-Sep-2003 08:01:44 PM # Author: Kurt Kincaid (sifukurt@yahoo.com) # Copyright(c) 2003, Kurt Kincaid # All Rights Reserved # # NOTICE: This package is free software and may be modified and/or # redistributed under the same terms as Perl itself. #--------------------------------------------------------------------# use Tk; use Tk::Dialog; use Tk::DialogBox; use Tk::Text; use Tk::FileSelect; use Tk::FileDialog; use Tk::Menu; use Tk::Menubutton; use Tk::widgets qw(Menu); use Tk::Checkbutton; use Tk::BrowseEntry; use File::Butler; use File::Glob; use Crypt::RC4; use Crypt::GOST_PP; use Crypt::TripleDES; use Crypt::CBC; use Crypt::Rijndael; use Crypt::RIPEMD160; use Crypt::PPDES; use Crypt::RC5; use Crypt::CBC; use Crypt::CAST5; use Crypt::RC6; use Crypt::Khazad; use Crypt::Anubis; use Crypt::Blowfish; use Crypt::Twofish2; use Crypt::Noekeon; use Crypt::Misty1; use Crypt::Rainbow; use Crypt::Serpent; use Crypt::Skipjack; use URI::Escape; use MIME::Base64; use Digest::MD2; use Digest::MD4; use Digest::MD5; use Digest::SHA1; use Digest::Haval256; use Acme::Playwright; use constant; use strict; use vars qw/ $temp_var $cipher $info $t $title $enc_type $mw $passphra +se $ref $algorithm $f $fileName $ea $help $saveas $des $aes $hex $hex2 $hex3 $hex4 $hex5 $hex6 $tripledes_header $tripledes_footer $rc4_header $rc4_footer $rc5_header $rc5_footer $cast5_header $cast5_footer $gost_header $gost_footer $m $fname $mod_date $FSref $ripemd $aes_header $aes_footer $VERSION $mm $tt $md2 $md4 $md5 $helptext $help_label $error @lines $sha $play_header $play_footer $anubis_header $anubis_footer %enc %dec $blowfish_header $blowfish_f +ooter $khazad_header $khazad_footer $noekeon_header $noekeon_footer $misty +1_header $misty1_footer $rainbow_header $rainbow_footer $rc6_header $rc6_foot +er $serpent_header $serpent_footer $skipjack_header $skipjack_footer $twofish_header $twofish_footer $haval $proc /; $VERSION = "3.10.01"; $mod_date = "30-Sep-2003 08:01:44 PM"; $title = "Cryptopad v" . $VERSION; $rc4_header = "----- CryptoPad RC4 Encrypted Message: Begin ---- +-\n"; $rc4_footer = "\n----- CryptoPad RC4 Encrypted Message: End ---- +-"; $tripledes_header = "----- CryptoPad TripleDES Encrypted Message: Begi +n -----\n"; $tripledes_footer = "\n----- CryptoPad TripleDES Encrypted Message: En +d -----"; $aes_header = "----- CryptoPad AES (Rijndael) Encrypted Message: + Begin -----\n"; $aes_footer = "\n----- CryptoPad AES (Rijndael) Encrypted Messag +e: End -----"; $gost_header = "----- CryptoPad GOST Encrypted Message: Begin --- +--\n"; $gost_footer = "\n----- CryptoPad GOST Encrypted Message: End --- +--"; $rc5_header = "----- CryptoPad RC5 Encrypted Message: Begin ---- +-\n"; $rc5_footer = "\n----- CryptoPad RC5 Encrypted Message: End ---- +-"; $cast5_header = "----- CryptoPad CAST5 Encrypted Message: Begin -- +---\n"; $cast5_footer = "\n----- CryptoPad CAST5 Encrypted Message: End -- +---"; $play_header = "----- CryptoPad Acme::Playwright Encrypted Messag +e: Begin -----\n"; $play_footer = "\n----- CryptoPad Acme::Playwright Encrypted Mess +age: End -----"; $anubis_header = "----- CryptoPad Anubis Encrypted Message: Begin - +----\n"; $anubis_footer = "\n----- CrtypoPad Anubis Encrypted Message: End - +----"; $blowfish_header = "----- CryptoPad Blowfish Encrypted Message: Begin + -----\n"; $blowfish_footer = "\n----- CrtypoPad Blowfish Encrypted Message: End + -----"; $khazad_header = "----- CryptoPad Khazad Encrypted Message: Begin - +----\n"; $khazad_footer = "\n----- CrtypoPad Khazad Encrypted Message: End - +----"; $noekeon_header = "----- CryptoPad Noekeon Encrypted Message: Begin +-----\n"; $noekeon_footer = "\n----- CrtypoPad Noekeon Encrypted Message: End +-----"; $misty1_header = "----- CryptoPad Misty1 Encrypted Message: Begin - +----\n"; $misty1_footer = "\n----- CrtypoPad Misty1 Encrypted Message: End - +----"; $rainbow_header = "----- CryptoPad Rainbow Encrypted Message: Begin +-----\n"; $rainbow_footer = "\n----- CrtypoPad Rainbow Encrypted Message: End +-----"; $rc6_header = "----- CryptoPad RC6 Encrypted Message: Begin ---- +-\n"; $rc6_footer = "\n----- CrtypoPad RC6 Encrypted Message: End ---- +-"; $serpent_header = "----- CryptoPad Serpent Encrypted Message: Begin +-----\n"; $serpent_footer = "\n----- CrtypoPad Serpent Encrypted Message: End +-----"; $skipjack_header = "----- CryptoPad Skipjack Encrypted Message: Begin + -----\n"; $skipjack_footer = "\n----- CrtypoPad Skipjack Encrypted Message: End + -----"; $twofish_header = "----- CryptoPad Twofish Encrypted Message: Begin +-----\n"; $twofish_footer = "\n----- CrtypoPad Twofish Encrypted Message: End +-----"; $proc = "Processing...."; %enc = ( 'aes' => \&aes_encrypt, 'tripledes' => \&tripledes_encrypt, 'gost' => \&gost_encrypt, 'rc4' => \&rc4_encrypt, 'rc5' => \&rc5_encrypt, 'rc6' => \&rc6_encrypt, 'cast5' => \&cast5_encrypt, 'playwright' => \&playwright_encrypt, 'anubis' => \&anubis_encrypt, 'blowfish' => \&blowfish_encrypt, 'khazad' => \&khazad_encrypt, 'misty1' => \&misty1_encrypt, 'noekeon' => \&noekeon_encrypt, 'serpent' => \&serpent_encrypt, 'skipjack' => \&skipjack_encrypt, 'twofish' => \&twofish_encrypt, 'rainbow' => \&rainbow_encrypt ); %dec = ( 'aes' => \&aes_decrypt, 'tripledes' => \&tripledes_decrypt, 'gost' => \&gost_decrypt, 'rc4' => \&rc4_decrypt, 'rc5' => \&rc5_decrypt, 'rc6' => \&rc6_decrypt, 'cast5' => \&cast5_decrypt, 'playwright' => \&playwright_decrypt, 'anubis' => \&anubis_decrypt, 'blowfish' => \&blowfish_decrypt, 'khazad' => \&khazad_decrypt, 'misty1' => \&misty1_decrypt, 'noekeon' => \&noekeon_decrypt, 'serpent' => \&serpent_decrypt, 'skipjack' => \&skipjack_decrypt, 'twofish' => \&twofish_decrypt, 'rainbow' => \&rainbow_decrypt ); $mw = MainWindow->new; $mw->title( $title ); $m = $mw->Frame( -relief => 'groove', -bd => 2 )->pack( -side => 'top' +, -anchor => 'n', -fill => 'x' ); $m->Menubutton( -text => "File", -tearoff => 0, -menuitems => [ [ "command" => "New", -command => \&clear ], [ "command" => "Open", -command => \&OpenDocument ], [ "command" => "Save", -command => \&SaveDocument ], [ "command" => "Save As", -command => \&SaveAs ], [ "command" => "Exit", -command => sub { exit } ] ] )->pack( -side => 'left' ); $ea = "ENCRYPTION ALGORITHM:"; $m->Menubutton( -text => "Algorithm", -tearoff => 0, -menuitems => [ [ "command" => "AES", -command => sub { $algorithm = "$ea AES"; $enc_type = "aes +"; } ], [ "command" => "Anubis", -command => sub { $algorithm = "$ea Anubis"; $enc_type = " +anubis"; } ], [ "command" => "Blowfish", -command => sub { $algorithm = "$ea Blowfish"; $enc_type = + "blowfish"; } ], [ "command" => "CAST5", -command => sub { $algorithm = "$ea CAST5"; $enc_type = "c +ast5"; } ], [ "command" => "GOST", -command => sub { $algorithm = "$ea GOST"; $enc_type = "go +st"; } ], [ "command" => "Khazad", -command => sub { $algorithm = "$ea Khazad"; $enc_type = " +khazad"; } ], [ "command" => "Misty1", -command => sub { $algorithm = "$ea Misty1"; $enc_type = " +misty1"; } ], [ "command" => "Noekeon", -command => sub { $algorithm = "$ea Noekeon"; $enc_type = +"noekeon"; } ], [ "command" => "Rainbow", -command => sub { $algorithm = "$ea Rainbow"; $enc_type = +"rainbow"; } ], [ "command" => "RC4", -command => sub { $algorithm = "$ea RC4"; $enc_type = "rc4 +"; } ], [ "command" => "RC5", -command => sub { $algorithm = "$ea RC5"; $enc_type = "rc5 +"; } ], [ "command" => "RC6", -command => sub { $algorithm = "$ea RC6"; $enc_type = "rc6 +"; } ], [ "command" => "Serpent", -command => sub { $algorithm = "$ea Serpent"; $enc_type = +"serpent"; } ], [ "command" => "Skipjack", -command => sub { $algorithm = "$ea Skipjack"; $enc_type = + "skipjack"; } ], [ "command" => "TripleDES", -command => sub { $algorithm = "$ea TripleDES"; $enc_type += "tripledes"; } ], [ "command" => "Twofish", -command => sub { $algorithm = "$ea Twofish"; $enc_type = +"twofish"; } ], [ "command" => "Acme::Playwright", -command => sub { $algorithm = "$ea Acme::Playwright"; $enc_type = "playwright"; } ] ] )->pack( -side => 'left' ); $m->Menubutton( -text => "Help", -tearoff => 0, -menuitems => [ [ "command" => "Help...", -command => \&help ], [ "command" => "About...", -command => \&about ] ] )->pack( -side => 'left' ); my $font = $mw->Frame( -bd => 2 )->pack( -side => 'top', -anchor => +'n', -fill => 'x' ); my $family = 'Courier'; my $be = $font->BrowseEntry( -label => 'Font: ', -variable=> \$fam +ily, -browsecmd => \&apply_font)->pack( -fill +=> 'x', -side => 'left', -anchor => 'n' ); $be->insert( 'end', sort $mw->fontFamilies ); my $size = 10; my $bentry = $font->BrowseEntry(-label => 'Size: ', -variable => \$siz +e, -browsecmd => \&apply_font)->pack(-side = +> 'left'); $bentry->insert( 'end', (3..32)); my $weight = 'normal'; $font->Checkbutton( -onvalue => 'bold', -offvalue=> 'normal', -text => 'Bold', -variable => \$weight, -command => \&apply_font)->pack(-side => 'left' ); my $slant = 'roman'; $font->Checkbutton(-onvalue => 'italic', -offvalue => 'roman', -text => 'Italic', -variable => \$slant, -command => \&apply_font)->pack( -side => 'left' ); my $underline = 0; $font->Checkbutton(-text => 'Underline', -variable => \$underline, -command => \&apply_font)->pack(-side => 'left' ); my $overstrike = 0; $font->Checkbutton(-text => 'Overstrike', -variable => \$overstrike, -command => \&apply_font)->pack(-side => 'left' ); $f = $mw->Frame->pack( -side => 'top', -fill => 'x' ); $f->Label( -text => "Passphrase:" )->pack( -side => 'left', -anchor => + 'w' ); $f->Entry( -show => '*', -textvariable => \$passphrase )->pack( -side => 'left', -anchor => 'w', -fill => 'x', -expand => 1 ); $f->Button( -text => "Message Digest", -command => \&Digest )->pack( - +side => 'right' ); $f->Button( -text => "Decrypt", -command => \&decrypt )->pack( -side = +> 'right', -anchor => 'e' ); $f->Button( -text => "Encrypt", -command => \&encrypt )->pack( -side = +> 'right', -anchor => 'e' ); if ( $algorithm eq "" ) { $algorithm = "No Encryption Algorithm Selected"; } $f->Button( -text => "Clear", -command => \&clear )->pack( -side => 'r +ight', -anchor => 'e' ); $mw->Label( -textvariable => \$algorithm, -relief => 'ridge' )->pack( +-side => 'top', -fill => 'x' ); $mw->Label( -textvariable => \$info, -relief => 'ridge' )->pack( -side + => 'bottom', -fill => 'x' ); $t = $mw->Scrolled( "Text", -wrap => 'word', -scrollbars => 'e' )->pac +k( -side => 'bottom', -fill => 'both', -expand => 1 ); $info = $title; #my $stext = $t->get( "1.0", "end" ); #my $sample = $mw->Entry( -textvariable => \$stext)->pack( -fill => 'x +'); &apply_font; MainLoop; #--------------------------------------------------------------------# # Encryption Sub-Routines #--------------------------------------------------------------------# sub encrypt { if ( $enc_type ) { $info = $proc; $temp_var = $t->get( "1.0", "end" ); chomp $temp_var; &{ $enc{ $enc_type } }; } else { Error( "Error", "No encryption algorithm has been selected. Pl +ease select an algorithm and try again." ); } } sub decrypt { if ( $enc_type ) { $info = "Processing...."; $temp_var = $t->get( "1.0", "end" ); chomp $temp_var; &{ $dec{ $enc_type } }; } else { Error( "Error", "No encryption algorithm has been selected. Pl +ease select an algorithm and try again." ); } } sub rc4_encrypt { if ( Confirm() ) { $cipher = RC4( $passphrase, $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $rc4_header . $cipher . $rc4_footer; $t->insert( "end", $cipher ); $info = $title; } } sub rc4_decrypt { if ( Confirm() ) { $temp_var =~ s/$rc4_header//; $temp_var =~ s/$rc4_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); $cipher = RC4( $passphrase, $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub rc5_encrypt { if ( Confirm() ) { my $ref = Crypt::RC5->new( $passphrase, 16 ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $rc5_header . $cipher . $rc5_footer; $t->insert( "end", $cipher ); $info = $title; } } sub rc5_decrypt { if ( Confirm() ) { $temp_var =~ s/$rc5_header//; $temp_var =~ s/$rc5_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::RC5->new( $passphrase, 16 ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub blowfish_encrypt { if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Blowfish" } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $blowfish_header . $cipher . $blowfish_footer; $t->insert( "end", $cipher ); $info = $title; } } sub blowfish_decrypt { if ( Confirm() ) { $temp_var =~ s/$blowfish_header//; $temp_var =~ s/$blowfish_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Blowfish" } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub twofish_encrypt { if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Twofish2" } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $twofish_header . $cipher . $twofish_footer; $t->insert( "end", $cipher ); $info = $title; } } sub twofish_decrypt { if ( Confirm() ) { $temp_var =~ s/$twofish_header//; $temp_var =~ s/$twofish_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Twofish2" } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub cast5_encrypt { if ( Confirm() ) { my $ref = Crypt::CBC->new( { key => $passphrase, cipher => "CAST5", } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $cast5_header . $cipher . $cast5_footer; $t->insert( "end", $cipher ); $info = $title; } } sub cast5_decrypt { if ( Confirm() ) { $temp_var =~ s/$cast5_header//; $temp_var =~ s/$cast5_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { key => $passphrase, cipher => "CAST5", } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub rc6_encrypt { if ( Confirm() ) { my $ref = Crypt::CBC->new( { key => $passphrase, cipher => "RC6", } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $rc6_header . $cipher . $rc6_footer; $t->insert( "end", $cipher ); $info = $title; } } sub rc6_decrypt { if ( Confirm() ) { $temp_var =~ s/$rc6_header//; $temp_var =~ s/$rc6_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { key => $passphrase, cipher => "RC6", } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub anubis_encrypt { my $IV = pack "H32", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Anubis", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $anubis_header . $cipher . $anubis_footer; $t->insert( "end", $cipher ); $info = $title; } } sub anubis_decrypt { my $IV = pack "H32", 0; if ( Confirm() ) { $temp_var =~ s/$anubis_header//; $temp_var =~ s/$anubis_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Anubis", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub rainbow_encrypt { my $IV = pack "H32", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Rainbow", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $rainbow_header . $cipher . $rainbow_footer; $t->insert( "end", $cipher ); $info = $title; } } sub rainbow_decrypt { my $IV = pack "H32", 0; if ( Confirm() ) { $temp_var =~ s/$rainbow_header//; $temp_var =~ s/$rainbow_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Rainbow", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub noekeon_encrypt { my $IV = pack "H32", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Noekeon", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $noekeon_header . $cipher . $noekeon_footer; $t->insert( "end", $cipher ); $info = $title; } } sub noekeon_decrypt { my $IV = pack "H32", 0; if ( Confirm() ) { $temp_var =~ s/$noekeon_header//; $temp_var =~ s/$noekeon_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Noekeon", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub skipjack_encrypt { my $IV = pack "H16", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Skipjack", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $skipjack_header . $cipher . $skipjack_footer; $t->insert( "end", $cipher ); $info = $title; } } sub skipjack_decrypt { my $IV = pack "H16", 0; if ( Confirm() ) { $temp_var =~ s/$skipjack_header//; $temp_var =~ s/$skipjack_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Skipjack", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub khazad_encrypt { my $IV = pack "H16", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Khazad", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $khazad_header . $cipher . $khazad_footer; $t->insert( "end", $cipher ); $info = $title; } } sub khazad_decrypt { my $IV = pack "H16", 0; if ( Confirm() ) { $temp_var =~ s/$khazad_header//; $temp_var =~ s/$khazad_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Khazad", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub serpent_encrypt { my $IV = pack "H16", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Serpent", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $serpent_header . $cipher . $serpent_footer; $t->insert( "end", $cipher ); $info = $title; } } sub serpent_decrypt { my $IV = pack "H16", 0; if ( Confirm() ) { $temp_var =~ s/$serpent_header//; $temp_var =~ s/$serpent_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Serpent", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub misty1_encrypt { my $IV = pack "H16", 0; if ( Confirm() ) { my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Misty1", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $misty1_header . $cipher . $misty1_footer; $t->insert( "end", $cipher ); $info = $title; } } sub misty1_decrypt { my $IV = pack "H16", 0; if ( Confirm() ) { $temp_var =~ s/$misty1_header//; $temp_var =~ s/$misty1_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); my $ref = Crypt::CBC->new( { 'key' => $passphrase, 'cipher' => "Misty1", 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 } ); $cipher = $ref->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub tripledes_encrypt { if ( Confirm() ) { my $des = new Crypt::TripleDES; $cipher = $des->encrypt3( $temp_var, $passphrase ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $tripledes_header . $cipher . $tripledes_footer; $t->insert( "end", $cipher ); $info = $title; } } sub tripledes_decrypt { if ( Confirm() ) { my $des = new Crypt::TripleDES; $temp_var =~ s/$tripledes_header//; $temp_var =~ s/$tripledes_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); $cipher = $des->decrypt3( $temp_var, $passphrase ); $cipher =~ s/\s*$//; chomp $cipher; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub aes_encrypt { if ( Confirm() ) { $aes = new Crypt::CBC( $passphrase, 'Rijndael' ); $cipher = $aes->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $aes_header . $cipher . $aes_footer; $t->insert( "end", $cipher ); $info = $title; } } sub aes_decrypt { if ( Confirm() ) { @lines = split ( /\n/, $temp_var ); shift @lines; pop @lines; $temp_var = join ( "", @lines ); $temp_var = Prep( $temp_var ); $aes = new Crypt::CBC( $passphrase, 'Rijndael' ); $cipher = $aes->decrypt( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub gost_encrypt { if ( Confirm() ) { my $ref = Crypt::GOST_PP->new( $passphrase ); $cipher = $ref->encrypt( $temp_var ); $info = ""; $t->delete( "1.0", "end" ); $cipher = encode_base64( $cipher ); $cipher =~ s/.{80}/$&\n/g; chomp $cipher; $cipher = $gost_header . $cipher . $gost_footer; $t->insert( "end", $cipher ); $info = $title; } } sub gost_decrypt { if ( Confirm() ) { my $ref = Crypt::GOST_PP->new( $passphrase ); $temp_var =~ s/$gost_header//; $temp_var =~ s/$gost_footer//; $temp_var =~ s/\n//g; $temp_var = Prep( $temp_var ); $cipher = $ref->decrypt( $temp_var ); $cipher =~ s/\s*$//; chomp $cipher; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } sub playwright_encrypt { if ( Confirm() ) { $cipher = Acme::Playwright::Make( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $cipher = $play_header . $cipher . $play_footer; $t->insert( "end", $cipher ); $info = $title; } } sub playwright_decrypt { if ( Confirm() ) { $temp_var =~ s/$play_header//; $temp_var =~ s/$play_footer//; $cipher = Acme::Playwright::UnMake( $temp_var ); chomp $cipher; $info = ""; $t->delete( "1.0", "end" ); $t->insert( "end", $cipher ); $info = $title; } } #--------------------------------------------------------------------# # End Encryption Sub-Routines #--------------------------------------------------------------------# sub clear { $t->delete( "1.0", "end" ); $passphrase = ""; $info = $title; $algorithm = "No Encryption Algorithm Selected"; $enc_type = ""; } sub about { $mw->Dialog( -title => "About...", -text => <<"END", -popover => $mw, -font => 'ansi' )->Show; $title Last Modified: $mod_date Copyright 2003 Kurt Kincaid. All rights reserved. Cryptopad is free software; you can redistribute it and/or modify it u +nder the same terms as Perl itself. END } sub Digest { $info = "Generating Message Digest...."; $hex = Digest::MD5->new(); $temp_var = $t->get( "1.0", "end" ); chomp $temp_var; if ( $temp_var eq "" ) { $info = $title; return; } $hex->add( $temp_var ); $md5 = $hex->hexdigest(); $hex2 = Digest::SHA1->new(); $hex2->add( $temp_var ); $sha = $hex2->hexdigest(); $hex3 = Digest::MD4->new(); $hex3->add( $temp_var ); $md4 = $hex3->hexdigest(); $hex4 = Digest::MD2->new(); $hex4->add( $temp_var ); $md2 = $hex4->hexdigest(); $hex5 = Crypt::RIPEMD160->new(); $hex5->reset(); $hex5->add( $temp_var ); $ripemd = $hex5->hexdigest(); $hex6 = Digest::Haval256->new(); $hex6->reset(); $hex6->add( $temp_var ); $haval = $hex6->hexdigest(); $mw->Dialog( -title => "Message Digest", -text => <<"END", -popover => $mw, -font => 'ansi' )->Show; [ SHA ] $sha [ MD5 ] $md5 [ MD4 ] $md4 [ MD2 ] $md2 [ RIPEMD-160 ] $ripemd [ Haval256 ] $haval END $info = $title; } sub OpenDocument { $FSref = $mw->FileSelect(); $fileName = $FSref->Show(); $temp_var = Butler( $fileName, "read" ); if ( !-e $fileName ) { $info = "Cannot open $fileName: $!"; return; } $t->delete( "1.0", "end" ); $t->insert( "end", $temp_var ); } sub SaveDocument { if ( $fileName eq "" ) { $saveas = $mw->FileDialog( -Title => 'Save As', -Create => 1 ) +; $saveas->Label( -text => "File Name: ", -relief => 'groove' ); $saveas->Entry( -width => 20, -textvariable => \$fileName ); $fname = $saveas->Show(); } $saveas->destroy(); $temp_var = $t->get( "1.0", "end" ); Butler( $fname, "write", \$temp_var ); $info = "$fname saved"; } sub SaveAs { undef $fileName; SaveDocument(); } sub help { $helptext = " $title Last Modified: $mod_date The encryption is accomplished with your choice of numerous encryption + algorithms. It should be noted that to avoid complications with disp +laying meta-characters, the encrypted output is escaped via MIME::Bas +e64. Starting with v2.02, Acme::Playwright is included as one of the +encryption algorithms. Please be advised that this is not, nor should + it be considered to be strong encryption. Rather, it is simple text +obfuscation in the form of a play. CryptoPad supports multiple rounds of encryption. For example, it is p +ossible to encrypt your data with TripleDES, then with AES, then with + RC4. Decryption would then be possible in the reverse order. The nam +e of the encryption algorithm is shown to facilitate this. It is impo +rtant to note that knowing which encryption algorithm was used in no +way diminishes the security of the encryption. The Message Digests are generated with SHA1, MD5, MD4, and MD2 Message + Digest algorithms by RSA Security Inc., RIPEMD-160 by Hans Dobbertin +, Antoon Bosselaers, and Haval256 by Bart Preneel, of Katholieke Univ +ersiteit Leuven, and Yuliang Zheng, Josef Pieprzyk, and Jennifer Sebe +rry.. "; $help_label = "$title Help"; $help = MainWindow->new(); $help->title( "Help" ); $mm = $help->Frame->pack( -side => 'top', -fill => 'x' ); $mm->Button( -text => "Close Window", -command => sub { $help->destroy() } )->pack( -side => 'right' ); $help->Label( -textvariable => \$help_label, -relief => 'ridge' )- +>pack( -side => 'bottom', -fill => 'x' ); $tt = $help->Scrolled( "Text", -width => 120, -wrap => 'word', -background => '#ffff88', -font => 'ansi', -scrollbars => 'e' )->pack( -side => 'bottom', -fill => 'both', -expand => 1 ); $tt->insert( "end", $helptext ); } sub Confirm { if ( $enc_type eq "playwright" ) { return 1; } if ( $temp_var eq "" ) { return 0; } if ( length( $passphrase ) < 5 ) { Error( "Passphrase Error", "The passphrase must be at least 5 +characters" ); return 0; } return 1; } sub Error { my $error; my ( $et, $em ) = @_; $error = $mw->Dialog( -bitmap => 'error', -title => $et, -text => <<"END", -popover => $mw, -font => 'ansi' )->Show; $em END $info = $title; } sub Prep { my $var = shift; if ( $var =~ /\%/ ) { $var = uri_unescape( $var ); } else { $var = decode_base64( $var ); } return $var; } sub apply_font { $t->configure( -font => [ -family => $family, -size => $size, -weight => $weight, -slant => $slant, -underline => $underline, -overstrike => $overstrike]); }

    ___________________
    Kurt
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://216561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2020-06-02 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (17 votes). Check out past polls.

    Notices?