File Coverage

blib/lib/Digest/PasswordComposer.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 4 4 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Digest::PasswordComposer;
2             {
3             $Digest::PasswordComposer::VERSION = '0.1';
4             }
5             # ABSTRACT: Generate unique passwords for web sites.
6              
7 4     4   139226 use strict;
  4         13  
  4         197  
8 4     4   25 use warnings;
  4         9  
  4         133  
9              
10 4     4   23 use Exporter;
  4         14  
  4         403  
11             our (@ISA, @EXPORT_OK);
12             @ISA = qw(Exporter);
13             @EXPORT_OK = qw(pwdcomposer);
14              
15 4     4   36 use Digest::MD5 qw(md5_hex);
  4         8  
  4         2094  
16              
17              
18              
19              
20             sub pwdcomposer {
21 3     3 1 14 my ($domain, $pwd) = @_;
22 3         40 return substr(md5_hex("$pwd:$domain"),0,8);
23             }
24              
25              
26             sub new {
27 2     2 1 944 my ($class) = @_;
28              
29 2         13 bless { domain => '' }, $class;
30             }
31              
32              
33             sub domain {
34 4     4 1 1014 my $self = shift;
35 4 100       18 if (@_) { $self->{domain} = shift }
  2         14  
36 4         22 return $self->{domain};
37             }
38              
39              
40             sub password {
41 2     2 1 8 my $self = shift;
42 2         7 return pwdcomposer($self->{domain},shift);
43             }
44              
45              
46             1;
47              
48              
49             __END__