-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcipher.pl
35 lines (26 loc) · 805 Bytes
/
cipher.pl
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
use strict;
use warnings;
use diagnostics;
use 5.014;
use Crypt::CBC;
use Crypt::Rijndael;
#use Crypt::Twofish;
sub md5 {
my $ctx = Digest::MD5->new;
$ctx->add($_[0]);
$ctx->hexdigest;
}
my $key = 'c6bef73b51e2f696';
my $iv = 'aa90025f918a9696';
my $text = "alessandra cristina dos santos";
#my $cbc = Crypt::CBC->new(cipher=>'Twofish', key=>$key, iv=>$iv);
my $cbc = Crypt::CBC->new(cipher=>'Rijndael', key=>$key, iv=>$iv);
my $ciphertext = $cbc->encrypt($text);
my $hexcipher = unpack("H*", $ciphertext);
my $decrypted = $cbc->decrypt(pack("H*", $hexcipher));
print "TEXT : $text\n";
printf " (MD5): %s\n", &md5($text);
print "ENCRYPTED: $hexcipher\n";
printf " (MD5): %s\n", &md5($hexcipher);
print "DECRYPTED: $decrypted\n";
printf " (MD5): %s\n", &md5($decrypted);