Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // client sends to proxy
- public ByteBuffer decryptClientGame(ByteBuffer packet, boolean first) {
- try {
- if(first) { // first packet, client sends to proxy.
- Cipher cii = Cipher.getInstance("Blowfish/CFB64/NoPadding");
- Key key = new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish");
- cii.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(" ".getBytes()));
- ByteBuffer bb = ByteBuffer.wrap(cii.doFinal(packet.array())).order(ByteOrder.LITTLE_ENDIAN);
- int len = bb.getInt(7);
- int junkLen = bb.getInt(11);
- int index = 15 + junkLen;
- int strLen = bb.getInt(index);
- index+=4;
- String p = new String(bb.array(), index, strLen);
- exchange.clientPubKey= new BigInteger(p, 16);
- System.out.println("Client Key len: " + p.length());
- cii.init(Cipher.ENCRYPT_MODE, key);//new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish"));
- return ByteBuffer.wrap(cii.doFinal(bb.array()));
- } else {
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- return packet;
- }
Add Comment
Please, Sign In to add comment