line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Type::ENCRYPT; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: ENCRYPT.pm,v 1.3 2003/09/09 00:11:59 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
188
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
6
|
|
|
6
|
|
20
|
use vars ('$VERSION', '@ISA'); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
256
|
|
8
|
6
|
|
|
6
|
|
21
|
use Carp "croak"; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
1024
|
|
9
|
|
|
|
|
|
|
use overload ( |
10
|
4
|
|
|
4
|
|
22
|
'eq' => sub { crypt($_[1], $_[0]->id) eq $_[0]->id }, |
11
|
0
|
0
|
|
0
|
|
0
|
bool => sub { $_[0]->id ? 1 : 0 }, |
12
|
6
|
|
|
|
|
52
|
fallback => 1 |
13
|
6
|
|
|
6
|
|
42
|
); |
|
6
|
|
|
|
|
6
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@ISA = ("Class::PObject::Type"); |
16
|
|
|
|
|
|
|
$VERSION = "1.00"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _init { |
19
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
20
|
2
|
50
|
|
|
|
9
|
defined( $self->id ) or return undef; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
51
|
my $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; |
23
|
2
|
|
|
|
|
7
|
$self->{id} = crypt($self->id, $salt) |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
__END__ |