RC4(3)
π RC4(3) β alleged rc4 encryption
okay so this is the page for setupRC4state, rc4, rc4skip, and rc4back, straight out of the Library Functions Manual, and bestie you're gonna want to sit down for this one because we're doing stream cipher vibes today π
β¨ NAME β¨
setupRC4state, rc4, rc4skip, rc4back β alleged rc4 encryption
(and yes, the manpage itself says alleged, we'll get to that, don't come for me π)
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
#include <mp.h>
#include <libsec.h>
void setupRC4state(RC4state *s, uchar *seed, int slen)
void rc4(RC4state *s, uchar *data, int dlen)
void rc4skip(RC4state *s, int nbytes)
void rc4back(RC4state *s, int nbytes)
like, four whole functions, all cute, all void, no return values to worry about π«Ά
π¦ DESCRIPTION π¦
so here's the tea: this is an algorithm alleged to be Rivest's RC4 encryption function. alleged β the manpage is being shady about it and honestly that's iconic of it π
it's a pseudo-random number generator with a 256 byte state and a long cycle. the way it works: your input buffer gets XOR'd with the output of the generator β and that same XOR is doing double duty, both to encrypt and to decrypt. symmetric king behavior, no cap π
the seed gets entered using setupRC4state, and it can be any length β literally any length, she's flexible like that, no fixed key size drama β¨
the generator can be run:
- forward using
rc4β the normal everyday path, main character energy - skipped over using
rc4skipβ this exists to account for lost transmissions, so if some bytes never made it to you, you just yeet past them - backwards using
rc4backβ for covering retransmitted data, so you can rewind when the network decides to send you the same thing twice π
and the RC4state structure is the one keeping track of the whole algorithm β she's holding the state, she's remembering everything, she's literally the backbone of this operation π
π SOURCE π
/src/libsec
go look, it's all there π§
π SEE ALSO π
the whole crypto friend group showing up to support, we love a crossover episode π
okay bestie that's the whole page, mwah π β this was RC4(3) from the Library Functions Manual, and while the footer's date stamp didn't make it onto this copy (she's timeless, she's mysterious β), the source version is living happily at /src/libsec forever. slay, stay encrypted, and remember: it's alleged π
πΈ
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms