Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte[] loginSucessDecrypted = decrypt(secret.getEncoded(), loginSuccessEncrypted, new IvParameterSpec(secret.getEncoded()), "AES/CFB/NoPadding", secret.getAlgorithm()) ; // packet size
- int loginPacketSize = readVarInt(loginSucessDecrypted[0]); // packet size
- if(loginPacketId != 0x02) { // We want login success
- System.out.println("Bad packet id: " + loginPacketId);
- if(loginPacketId == 0x00) { // If it's a disconnect packet
- disconnected(input);
- }
- }
- public static byte[] decrypt(byte[] secretKey, byte[] data, IvParameterSpec iv, String ALGORITHM, String SecretKeyAlgo) throws Exception {
- SecretKey key = new SecretKeySpec(secretKey, SecretKeyAlgo);
- Cipher cipher = Cipher.getInstance(ALGORITHM);
- cipher.init(Cipher.DECRYPT_MODE, key, iv);
- // hopefully original secret converted secret and iv stay the same
- System.out.println("Lets hope these 3 are the same: " + Arrays.toString(secretKey) +" "+ Arrays.toString(key.getEncoded())+
- " "+ Arrays.toString(iv.getIV()));
- byte[] decryptedBytes = cipher.doFinal(data);
- return decryptedBytes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement