blib/lib/Crypt/CVS.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 95.1% 39 / 41 CC 2 SCAR 2.2
CC
2
Cov
100%
descramble
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Crypt::CVS;
2 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 $Crypt::CVS::AUTHORITY = 'cpan:AVAR';
4 }
5 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $Crypt::CVS::VERSION = '0.03';
7 }
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our @EXPORT = ();
14 2 our @EXPORT_OK = qw(scramble descramble);
15 2 our %EXPORT_TAGS;
16 2 $EXPORT_TAGS{'all'} = \@EXPORT_OK;
17  
18 # This table is from src/scramble.c in the CVS source
19 2 our @SHIFTS = (
20 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
21 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
22 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,
23 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,
24 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,
25 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,
26 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
27 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,
28 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
29 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
30 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
31 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
32 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
33 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
34 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
35 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
36 );
37  
38 sub scramble
39 1257 ▶{
Subroutine scramble: called CC=1 SCAR=0.0
Pod undocumented
40 1257 my ($str) = @_;
41 1257 my @str = unpack "C*", $str;
42 1257 my $ret = join '', map { chr $SHIFTS[$_] } @str;
43 1257 return "A$ret";
44 }
45  
46 sub descramble
47 1062 ▶{
Subroutine descramble: called CC=2 SCAR=6.9
Pod undocumented
48 1062 my ($str) = @_;
49  
50 # This should never happen, the same password format (A) has been
51 # used by CVS since the beginning of time
52 {
53 1062 my $fmt = substr($str, 0, 1);
54 1062 ▶ die "invalid password format `$fmt'" unless $fmt eq 'A';
Branch: 1 branch
BranchTrueFalseTotal
unless $fmt eq "A" 61 1001 1062
55 }
56  
57 1001 my @str = unpack "C*", substr($str, 1);
58 1001 my $ret = join '', map { chr $SHIFTS[$_] } @str;
59 1001 return $ret;
60 }
61  
62 2 1;
63  
64 __END__
↑ Summary