| 1 | package Convert::SSH2::Format::Base; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | our $VERSION = '0.01'; | |||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | Convert::SSH2::Format::Base - Base class for SSH2 formatters | ||||||||||
| 10 | |||||||||||
| 11 | =head1 PURPOSE | ||||||||||
| 12 | |||||||||||
| 13 | Subclass this module to implement your own RSA SSH2 key reformatters. | ||||||||||
| 14 | |||||||||||
| 15 | =head1 ATTRIBUTES | ||||||||||
| 16 | |||||||||||
| 17 | =over | ||||||||||
| 18 | |||||||||||
| 19 | =item e | ||||||||||
| 20 | |||||||||||
| 21 | The public exponent component of an RSA public key. | ||||||||||
| 22 | |||||||||||
| 23 | =back | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 2 | has 'e' => ( | |||||||||
| 28 | is => 'ro', | ||||||||||
| 29 | required => 1, | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | =over | ||||||||||
| 33 | |||||||||||
| 34 | =item n | ||||||||||
| 35 | |||||||||||
| 36 | The modulus component of an RSA public key. | ||||||||||
| 37 | |||||||||||
| 38 | =back | ||||||||||
| 39 | |||||||||||
| 40 | =cut | ||||||||||
| 41 | |||||||||||
| 42 | 2 | has 'n' => ( | |||||||||
| 43 | is => 'ro', | ||||||||||
| 44 | required => 1, | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | =over | ||||||||||
| 48 | |||||||||||
| 49 | =item line_width | ||||||||||
| 50 | |||||||||||
| 51 | How many characters should make a line. Defaults to 64. | ||||||||||
| 52 | |||||||||||
| 53 | =back | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | |||||||||||
| 57 | has 'line_width' => ( | ||||||||||
| 58 | is => 'ro', | ||||||||||
| 59 | 4 | ▶ | default => sub { 64 }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 60 | 2 | ); | |||||||||
| 61 | |||||||||||
| 62 | =head1 METHOD | ||||||||||
| 63 | |||||||||||
| 64 | =over | ||||||||||
| 65 | |||||||||||
| 66 | =item generate() | ||||||||||
| 67 | |||||||||||
| 68 | Using C<n> and C<e>, generate a representation in a specific format. | ||||||||||
| 69 | |||||||||||
| 70 | =back | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub generate { | ||||||||
|
Subroutine
generate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 75 | 0 | die "Subclass me."; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | =over | ||||||||||
| 79 | |||||||||||
| 80 | =item format_lines() | ||||||||||
| 81 | |||||||||||
| 82 | Given a string, insert newlines every C<line_width> characters. | ||||||||||
| 83 | |||||||||||
| 84 | Returns formatted string. | ||||||||||
| 85 | |||||||||||
| 86 | =back | ||||||||||
| 87 | |||||||||||
| 88 | =cut | ||||||||||
| 89 | |||||||||||
| 90 | 4 | ▶ | sub format_lines { | ||||||||
|
Subroutine
format_lines: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 91 | 4 | my $self = shift; | |||||||||
| 92 | 4 | my $string = shift; | |||||||||
| 93 | |||||||||||
| 94 | 4 | my $out; | |||||||||
| 95 | 4 | my $len = length($string); | |||||||||
| 96 | 4 | ▶ | for ( my $pos = 0 ; $pos < $len ; $pos += $self->line_width ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | 36 | $out .= substr($string, $pos, $self->line_width) . "\n"; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 4 | return $out; | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | =head1 SEE ALSO | ||||||||||
| 104 | |||||||||||
| 105 | L<Convert::SSH2> | ||||||||||
| 106 | |||||||||||
| 107 | =cut | ||||||||||
| 108 | |||||||||||
| 109 | 2 | 1; | |||||||||