1RC4(3) User Contributed Perl Documentation RC4(3)
2
3
4
6 Crypt::RC4 - Perl implementation of the RC4 encryption algorithm
7
9 # Functional Style
10 use Crypt::RC4;
11 $encrypted = RC4( $passphrase, $plaintext );
12 $decrypt = RC4( $passphrase, $encrypted );
13
14 # OO Style
15 use Crypt::RC4;
16 $ref = Crypt::RC4->new( $passphrase );
17 $encrypted = $ref->RC4( $plaintext );
18
19 $ref2 = Crypt::RC4->new( $passphrase );
20 $decrypted = $ref2->RC4( $encrypted );
21
22 # process an entire file, one line at a time # (Warning: Encrypted file
23 leaks line lengths.)
24 $ref3 = Crypt::RC4->new( $passphrase );
25 while (<FILE>) {
26 chomp;
27 print $ref3->RC4($_), "\n";
28 }
29
31 A simple implementation of the RC4 algorithm, developed by RSA
32 Security, Inc. Here is the description from RSA's website:
33
34 RC4 is a stream cipher designed by Rivest for RSA Data Security (now
35 RSA Security). It is a variable key-size stream cipher with byte-
36 oriented operations. The algorithm is based on the use of a random
37 permutation. Analysis shows that the period of the cipher is
38 overwhelmingly likely to be greater than 10100. Eight to sixteen
39 machine operations are required per output byte, and the cipher can be
40 expected to run very quickly in software. Independent analysts have
41 scrutinized the algorithm and it is considered secure.
42
43 Based substantially on the "RC4 in 3 lines of perl" found at
44 http://www.cypherspace.org
45
46 A major bug in v1.0 was fixed by David Hook (dgh@wumpus.com.au).
47 Thanks, David.
48
50 Kurt Kincaid (sifukurt@yahoo.com) Ronald Rivest for RSA Security, Inc.
51
53 Disclaimer: Strictly speaking, this module uses the "alleged" RC4
54 algorithm. The Algorithm known as "RC4" is a trademark of RSA Security
55 Inc., and this document makes no claims one way or another that this is
56 the correct algorithm, and further, make no claims about the quality of
57 the source code nor any licensing requirements for commercial use.
58
59 There's nothing preventing you from using this module in an insecure
60 way which leaks information. For example, encrypting multilple messages
61 with the same passphrase may allow an attacker to decode all of them
62 with little effort, even though they'll appear to be secured. If
63 serious crypto is your goal, be careful. Be very careful.
64
65 It's a pure-Perl implementation, so that rating of "Eight to sixteen
66 machine operations" is good for nothing but a good laugh. If
67 encryption and decryption are a bottleneck for you, please re-write
68 this module to use native code wherever practical.
69
71 This is free software and may be modified and/or redistributed under
72 the same terms as Perl itself.
73
75 perl, <http://www.cypherspace.org>, <http://www.rsasecurity.com>,
76 <http://www.achtung.com/crypto/rc4.html>,
77 <http://www.columbia.edu/~ariel/ssleay/rrc4.html>
78
79
80
81perl v5.38.0 2023-07-20 RC4(3)