Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // client sends to proxy
  2. public ByteBuffer decryptClientGame(ByteBuffer packet, boolean first) {
  3. try {
  4.  
  5.  
  6. if(first) { // first packet, client sends to proxy.
  7. Cipher cii = Cipher.getInstance("Blowfish/CFB64/NoPadding");
  8. Key key = new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish");
  9. cii.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(" ".getBytes()));
  10. ByteBuffer bb = ByteBuffer.wrap(cii.doFinal(packet.array())).order(ByteOrder.LITTLE_ENDIAN);
  11. int len = bb.getInt(7);
  12. int junkLen = bb.getInt(11);
  13. int index = 15 + junkLen;
  14. int strLen = bb.getInt(index);
  15. index+=4;
  16. String p = new String(bb.array(), index, strLen);
  17. exchange.clientPubKey= new BigInteger(p, 16);
  18. System.out.println("Client Key len: " + p.length());
  19.  
  20.  
  21. cii.init(Cipher.ENCRYPT_MODE, key);//new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish"));
  22. return ByteBuffer.wrap(cii.doFinal(bb.array()));
  23.  
  24. } else {
  25.  
  26. }
  27.  
  28.  
  29. } catch(Exception e) {
  30. e.printStackTrace();
  31. }
  32. return packet;
  33. }
Add Comment
Please, Sign In to add comment