blib/lib/Crypt/Stream/RC4.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 16 / 16 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Crypt/Stream/ChaCha.pm ↑ Summary blib/lib/Crypt/Stream/Rabbit.pm »
1 package Crypt::Stream::RC4;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 our $VERSION = '0.091';
6  
7 3 ▶use CryptX;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶sub CLONE_SKIP { 1 } # prevent cloning
Subroutine CLONE_SKIP: called CC=1 SCAR=0.0
10  
11 3 1;
12  
13 =pod
14  
15 =head1 NAME
16  
17 Crypt::Stream::RC4 - Stream cipher RC4
18  
19 =head1 SYNOPSIS
20  
21 use Crypt::Stream::RC4;
22  
23 # encrypt
24 my $key = "1234567890123456";
25 my $enc_stream = Crypt::Stream::RC4->new($key);
26 my $ct = $enc_stream->crypt("plain message");
27  
28 # decrypt
29 my $dec_stream = Crypt::Stream::RC4->new($key);
30 my $pt = $dec_stream->crypt($ct);
31  
32 =head1 DESCRIPTION
33  
34 Provides an interface to the RC4 stream cipher.
35  
36 =head1 METHODS
37  
38 Unless noted otherwise, assume C<$stream> is an existing stream object created
39 via C<new>, for example:
40  
41 my $stream = Crypt::Stream::RC4->new($key);
42  
43 =head2 new
44  
45 my $stream = Crypt::Stream::RC4->new($key);
46 # $key .. [binary string] length 5-256 bytes (40 - 2048 bits)
47  
48 =head2 crypt
49  
50 Encrypts or decrypts data. The output has the same length as the input.
51 Returns a binary string (raw bytes).
52  
53 The input is converted using Perl's usual scalar stringification. Passing
54 C<undef> is treated as an empty string with the usual warning, and numeric
55 scalars are stringified before processing.
56  
57 my $ciphertext = $stream->crypt($plaintext);
58 #or
59 my $plaintext = $stream->crypt($ciphertext);
60  
61 =head2 keystream
62  
63 Returns C<$length> bytes of raw keystream as a binary string.
64  
65 The length is taken using Perl's usual numeric coercion. Values that coerce to
66 an oversized unsigned length are rejected as too large.
67  
68 my $random_key = $stream->keystream($length);
69  
70 =head2 clone
71  
72 Returns a copy of the stream cipher object in its current state.
73  
74 my $stream2 = $stream->clone();
75  
76 =head1 SEE ALSO
77  
78 =over
79  
80 =item * L<Crypt::Stream::ChaCha>, L<Crypt::Stream::Sober128>, L<Crypt::Stream::Salsa20>, L<Crypt::Stream::Sosemanuk>
81  
82 =item * L<https://en.wikipedia.org/wiki/RC4_cipher>
83  
84 =back
85  
86 =cut
« blib/lib/Crypt/Stream/ChaCha.pm ↑ Summary blib/lib/Crypt/Stream/Rabbit.pm »