Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nanomice.nanomice;
- import java.io.ByteArrayInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- /**
- *
- * @author Ruslan Devsaider <me@devsaider.ru>
- */
- public class TransformicePacket {
- public ByteArrayOutputStream rawb = new ByteArrayOutputStream();
- public DataOutputStream b = new DataOutputStream(rawb);
- public final int CC;
- public final int C;
- private static final int[] SECRET_KEY = {19, 41, 50, 15, 47, 56, 5, 49, 33, 36, 109, 72, 112, 109, 86, 116, 97, 98, 88, 74};
- public TransformicePacket(int C, int CC) throws IOException {
- this.C = C;
- this.CC = CC;
- this.b.writeByte(C);
- this.b.writeByte(CC);
- }
- static DataInputStream decode(int fingerprint, DataInputStream dis) throws IOException {
- ByteArrayOutputStream rawnewdis = new ByteArrayOutputStream();
- DataOutputStream newdis = new DataOutputStream(rawnewdis);
- while (dis.available() > 0) {
- fingerprint = (fingerprint + 1) % SECRET_KEY.length;
- newdis.write(dis.readByte() ^ SECRET_KEY[fingerprint]);
- }
- return new DataInputStream(new ByteArrayInputStream(rawnewdis.toByteArray()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement