function sc=rc4key(key) % rc4key - return key schedule array for key k % SEEMS BROKEN - bytes 2-9 are swapped with other key schedule bytes % At best, not compatible with 'real' RC4. At worst, also more vulnerable % set up the array le = length(key); sc = 0:255; j0 = 0; % scramble the key schedule for i0 = 0:255 k0 = floor(mod( key( floor(mod(i0,le))+1 ), 256)); j0 = floor(mod( j0 + k0 + sc(i0+1), 256)); tm = sc(i0+1); sc(i0+1) = sc(j0+1); sc(j0+1) = tm; end