RC4(3)
π NAME π
okay so bestie, welcome to this User Contributed Perl Documentation page for RC4(3) β aka Crypt::RC4, which is literally a Perl implementation of the RC4 encryption algorithm. thatβs the whole name, no cap β¨
πΈ SYNOPSIS πΈ
there are two ways to run this: the functional style and the OO style. both are valid, both are iconic, pick your vibe π
# Functional Style
use Crypt::RC4;
$encrypted = RC4( $passphrase, $plaintext );
$decrypt = RC4( $passphrase, $encrypted );
# OO Style
use Crypt::RC4;
$ref = Crypt::RC4->new( $passphrase );
$encrypted = $ref->RC4( $plaintext );
$ref2 = Crypt::RC4->new( $passphrase );
$decrypted = $ref2->RC4( $encrypted );
# process an entire file, one line at a time # (Warning: Encrypted file
leaks line lengths.)
$ref3 = Crypt::RC4->new( $passphrase );
while (<FILE>) {
chomp;
print $ref3->RC4($_), "\n";
}
quick heads-up: that warning about encrypted files leaking line lengths is very real, so donβt sleep on it π
π¦ DESCRIPTION π¦
so this is a simple implementation of the RC4 algorithm, developed by RSA Security, Inc. hereβs the description straight from RSAβs website:
RC4 is a stream cipher designed by Rivest for RSA Data Security (now RSA Security). It is a variable key-size stream cipher with byte-oriented operations. The algorithm is based on the use of a random permutation. Analysis shows that the period of the cipher is overwhelmingly likely to be greater than 10100. Eight to sixteen machine operations are required per output byte, and the cipher can be expected to run very quickly in software. Independent analysts have scrutinized the algorithm and it is considered secure.
itβs based substantially on the "RC4 in 3 lines of perl" found at http://www.cypherspace.org β cute, right? π
also, a major bug in v1.0 was fixed by David Hook (dgh@wumpus.com.au). thanks, David! π«Ά
π AUTHOR π
shoutout to Kurt Kincaid (sifukurt@yahoo.com) and Ronald Rivest for RSA Security, Inc. β thatβs the author credit on this page, periodt π
π BUGS π
Disclaimer: strictly speaking, this module uses the "alleged" RC4 algorithm. The Algorithm known as "RC4" is a trademark of RSA Security Inc., and this document makes no claims one way or another that this is the correct algorithm, and further, make no claims about the quality of the source code nor any licensing requirements for commercial use.
Thereβs nothing preventing you from using this module in an insecure way which leaks information. for example, encrypting multilple messages with the same passphrase may allow an attacker to decode all of them with little effort, even though theyβll appear to be secured. if serious crypto is your goal, be careful. Be very careful. π
itβs a pure-Perl implementation, so that rating of "Eight to sixteen machine operations" is good for nothing but a good laugh. if encryption and decryption are a bottleneck for you, please re-write this module to use native code wherever practical. ngl, that part is giving βdo it yourselfβ energy π
π LICENSE π
this is free software and may be modified and/or redistributed under the same terms as Perl itself. slay π
π SEE ALSO π
perl<http://www.cypherspace.org><http://www.rsasecurity.com><http://www.achtung.com/crypto/rc4.html><http://www.columbia.edu/~ariel/ssleay/rrc4.html>
okay bye bestie β this page is from perl v5.42.0, dated 2025-05-09, and its manual tag is RC4(3). π
π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Crypt-RC4 2.02-160000.2.2 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Crypt-RC4 2.02-160000.2.2 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Crypt-RC4 2.02-160000.2.2 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Crypt-RC4 2.02-160000.2.2 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms