-
Notifications
You must be signed in to change notification settings - Fork 1
/
Blowfish.pm
74 lines (46 loc) · 1.3 KB
/
Blowfish.pm
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
package Crypt::OpenSSL::Blowfish;
use strict;
use Carp;
use vars qw/$VERSION @ISA/;
require DynaLoader;
@ISA = qw/DynaLoader/;
$VERSION = '0.02';
bootstrap Crypt::OpenSSL::Blowfish $VERSION;
sub blocksize { 8; }
sub keysize { 0; }
sub min_keysize { 8; }
sub max_keysize { 56; }
sub new {
my $self = {};
bless $self, shift;
$self->{ks} = Crypt::OpenSSL::Blowfish::init(shift);
$self;
}
sub encrypt {
my ($self, $data) = @_;
Crypt::OpenSSL::Blowfish::crypt($data, $self->{ks}, 0);
$data;
}
sub decrypt {
my ($self, $data) = @_;
Crypt::OpenSSL::Blowfish::crypt($data, $self->{ks}, 1);
$data;
}
1;
__END__
=head1 NAME
Crypt::OpenSSL::Blowfish - Blowfish Algorithm using OpenSSL
=head1 SYNOPSIS
use Crypt::OpenSSL::Blowfish;
my $cipher = new Crypt::OpenSSL::Blowfish $key;
my $ciphertext = $cipher->encrypt($plaintext);
$plaintext = $cipher->decrypt($ciphertext);
=head1 DESCRIPTION
Crypt::OpenSSL::Blowfish implements the Blowfish Algorithm using functions contained in the OpenSSL crypto library.
Crypt::OpenSSL::Blowfish has an interface similar to Crypt::Blowfish, but produces different result than Crypt::Blowfish.
=head1 SEE ALSO
L<Crypt::Blowfish>
http://www.openssl.org/
=head1 AUTHOR
Vitaly Kramskikh, E<lt>[email protected]<gt>
=cut