line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuX::User::Util; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2422
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
|
|
36
|
use Sub::Exporter -setup => { |
9
|
|
|
|
|
|
|
exports => [qw( |
10
|
|
|
|
|
|
|
crypt_password |
11
|
|
|
|
|
|
|
)], |
12
|
2
|
|
|
2
|
|
15
|
}; |
|
2
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
1450
|
use Class::MOP; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
310
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub crypt_password { |
18
|
4
|
|
|
4
|
1
|
3229
|
my @args = @_; |
19
|
|
|
|
|
|
|
|
20
|
4
|
50
|
|
|
|
32
|
unshift @args, "passphrase" if @args % 2 == 1; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
18
|
my %args = @args; |
23
|
|
|
|
|
|
|
|
24
|
4
|
50
|
|
|
|
21
|
unless ( exists $args{class} ) { |
25
|
4
|
|
|
|
|
29
|
%args = ( |
26
|
|
|
|
|
|
|
class => "Authen::Passphrase::SaltedDigest", |
27
|
|
|
|
|
|
|
salt_random => 20, |
28
|
|
|
|
|
|
|
algorithm => "SHA-1", |
29
|
|
|
|
|
|
|
%args, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
22
|
my $class = delete $args{class}; |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
25
|
Class::MOP::load_class($class); |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
32566
|
$class->new(%args); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__PACKAGE__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
KiokuX::User::Util - Utility functions for L<KiokuX::User> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use KiokuX::User::Util; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
MyFoo::User->new( |
55
|
|
|
|
|
|
|
id => "cutegirl17", |
56
|
|
|
|
|
|
|
password => crypt_password("justin timberlake!!!"), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module provides utility functions. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 EXPORTS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item crypt_password @args |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If an even sized list is passed the first argument is assumed to be 'passphrase'. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Defaults to creating a L<Authen::Passphrase::SaltedDigest> with a 20 byte |
72
|
|
|
|
|
|
|
random salt. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ex: set sw=4 et: |
79
|
|
|
|
|
|
|
|