#include typedef unsigned char ch; typedef struct {ch s[256]; ch j;} state; void initst(state * st, ch * key){ {int j=256; while(j--) st->s[j] = j;} {int i, j=0, len = strlen((char*)key); for(i=0; i<256; ++i) {j = (j + st->s[i] + key[i%len])&255; {ch t=st->s[i]; st->s[i]=st->s[j]; st->s[j]=t;}}} st->j = 0;}