I don't know if your program correctly implements the RC4 algorithm.
However, there are issues with the coding style, which make your program very hard to read and understand.
Please indent your code properly, instead of starting every line at the leftmost column. Proper indentation makes it much easier to see the structure of the program.
Use meaningful variable names. You are using many one- or two-letter variable names that don't show the meaning of the variable. Also, in
Java, the most commonly accepted coding style is that variable names start with a lower-case letter (and class names start with an upper-case letter).
Also, you are not using
static correctly, mixing
static and non-
static member variables. It looks like you only made the member
cipher static because you got an error "non-static member cannot be accessed from a static context" when you tried to use
cipher from the
main method. Study
Understanding Class Members to understand what
static means and when
you should or should not use it.
Also, you are doing all the work in the constructor of the class
RC4algo. That's not good OO design. Constructors should only be used to initialize the state of an object, not to do the majority of the work that a class needs to do.