Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int i = 0;
- private int j = 0;
- private int[] Table;
- public HabboRC4() {
- Table = new int[0x0100];
- }
- public void init(final byte[] Key) {
- int k = Key.length;
- this.i = 0;
- while(this.i < 0x0100) {
- this.Table[this.i] = this.i;
- this.i++;
- }
- this.j = 0;
- this.i = 0;
- while (this.i < 0x0100)
- {
- this.j = (((this.j + this.Table[this.i]) + Key[(this.i % k)]) % 0x0100);
- this.mk(this.i, this.j);
- this.i++;
- };
- this.i = 0;
- this.j = 0;
- }
- public byte[] parse(final byte[] b) {
- int k;
- byte[] y = new byte[b.length];
- int position = 0;
- for(int a = 0; a < b.length; a++) {
- this.i = ((this.i + 1) % 0x0100);
- this.j = ((this.j + this.Table[this.i]) % 0x0100);
- this.mk(this.i, this.j);
- k = ((this.Table[this.i] + this.j) % 0x0100);
- y[position++] = ((byte)(this.Table[k] ^ b[a]));
- }
- return y;
- }
- private void mk (final int k, final int y) {
- int x = this.Table[k];
- this.Table[k] = this.Table[y];
- this.Table[y] = x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement