function [r, i0, j0, sc]=rc4out(i0, j0, sc) % next byte of rc4 output % inputs: i0, j0 = indices; sc = key schedule % outputs: r=random byte; i0, j0 = indices; sc = key schedule i0 = mod( (i0+1), 256); j0 = mod( j0 + sc(i0+1), 256); tmp = sc(j0+1); sc(j0+1) = sc(i0+1); sc(i0+1) = tmp; r = mod( tmp + sc(j0+1), 256);