line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Digest::BubbleBabble; |
2
|
2
|
|
|
2
|
|
740
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
90
|
|
3
|
2
|
|
|
2
|
|
55
|
use 5.008_001; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
130
|
|
6
|
2
|
|
|
2
|
|
13
|
use vars qw( @EXPORT_OK @ISA $VERSION ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
219
|
|
7
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
8
|
|
|
|
|
|
|
@EXPORT_OK = qw( bubblebabble ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
12
|
use vars qw( @VOWELS @CONSONANTS ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1002
|
|
13
|
|
|
|
|
|
|
@VOWELS = qw( a e i o u y ); |
14
|
|
|
|
|
|
|
@CONSONANTS = qw( b c d f g h k l m n p r s t v z x ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub bubblebabble { |
17
|
4
|
|
|
4
|
1
|
36
|
my %param = @_; |
18
|
4
|
|
|
|
|
33
|
my @dgst = map ord, split //, $param{Digest}; |
19
|
4
|
|
|
|
|
12
|
my $dlen = length $param{Digest}; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
6
|
my $seed = 1; |
22
|
4
|
|
|
|
|
9
|
my $rounds = int($dlen / 2) + 1; |
23
|
4
|
|
|
|
|
5
|
my $retval = 'x'; |
24
|
4
|
|
|
|
|
9
|
for my $i (0..$rounds-1) { |
25
|
23
|
100
|
100
|
|
|
82
|
if ($i+1 < $rounds || $dlen % 2) { |
26
|
20
|
|
|
|
|
30
|
my $idx0 = ((($dgst[2 * $i] >> 6) & 3) + $seed) % 6; |
27
|
20
|
|
|
|
|
21
|
my $idx1 = ($dgst[2 * $i] >> 2) & 15; |
28
|
20
|
|
|
|
|
34
|
my $idx2 = (($dgst[2 * $i] & 3) + $seed / 6) % 6; |
29
|
20
|
|
|
|
|
29
|
$retval .= $VOWELS[$idx0] . $CONSONANTS[$idx1] . $VOWELS[$idx2]; |
30
|
20
|
100
|
|
|
|
41
|
if ($i+1 < $rounds) { |
31
|
19
|
|
|
|
|
26
|
my $idx3 = ($dgst[2 * $i + 1] >> 4) & 15; |
32
|
19
|
|
|
|
|
23
|
my $idx4 = $dgst[2 * $i + 1] & 15; |
33
|
19
|
|
|
|
|
33
|
$retval .= $CONSONANTS[$idx3] . '-' . $CONSONANTS[$idx4]; |
34
|
19
|
|
|
|
|
36
|
$seed = ($seed * 5 + $dgst[2 * $i] * 7 + |
35
|
|
|
|
|
|
|
$dgst[2 * $i + 1]) % 36; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
6
|
my $idx0 = $seed % 6; |
40
|
3
|
|
|
|
|
12
|
my $idx1 = 16; |
41
|
3
|
|
|
|
|
8
|
my $idx2 = $seed / 6; |
42
|
3
|
|
|
|
|
16
|
$retval .= $VOWELS[$idx0] . $CONSONANTS[$idx1] . $VOWELS[$idx2]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
4
|
|
|
|
|
9
|
$retval .= 'x'; |
46
|
4
|
|
|
|
|
28
|
$retval; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |