короче смотри, надо сделать дешифрование вот строки из сервера private static final…
- User
короче смотри, надо сделать дешифрование вот строки из сервера private static final String SPLITTER_CMDS = "end~"; private StringBuffer inputRequest; private StringBuffer badRequest = new StringBuffer(); public LobbyManager lobby; public Auth auth; private Channel channel; private ChannelHandlerContext context; private int _lastKey = 1; private final int[] _keys = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}; // � � : � � � � ℎ � � � � � � � � � � � � � � � � � � � � � � � � � [ ] FF:syntheticfieldprivatestaticint[]SWITCH_TABLE � � � � � � gtankscommands$Type;
public ProtocolTransfer(Channel channel, ChannelHandlerContext context) { this.channel = channel; this.context = context; }
public void decryptProtocol(String protocol) { if ((this.inputRequest = new StringBuffer(protocol)).length() > 0) { if (this.inputRequest.toString().endsWith("end~")) { this.inputRequest = new StringBuffer(StringUtils.concatStrings(this.badRequest.toString(), this.inputRequest.toString())); String[] var5; int var4 = (var5 = this.parseCryptRequests()).length;
for(int var3 = 0; var3 < var4; ++var3) { String request = var5[var3]; int key; try { key = Integer.parseInt(String.valueOf(request.charAt(0))); } catch (Exception var8) { Logger.log("[EXCEPTION] Detected cheater(replace protocol): " + this.channel.toString()); NettyUsersHandler.block(this.channel.getRemoteAddress().toString().split(":")[0]); this.closeConnection(); return; } if (key == this._lastKey) { Logger.log("Detected cheater(replace protocol): " + this.channel.toString()); NettyUsersHandler.block(this.channel.getRemoteAddress().toString().split(":")[0]); this.closeConnection(); return; } int nextKey = (this._lastKey + 1) % this._keys.length; if (key != (nextKey == 0 ? 1 : nextKey)) { Logger.log("[NOT QUEQUE KEY " + nextKey + " " + this._lastKey + "] Detected cheater(replace protocol): " + this.channel.toString()); NettyUsersHandler.block(this.channel.getRemoteAddress().toString().split(":")[0]); this.closeConnection(); return; } this.inputRequest = new StringBuffer(this.decrypt(request.substring(1, request.length()), key)); this.sendRequestToManagers(this.inputRequest.toString()); } this.badRequest = new StringBuffer(); } else { this.badRequest = new StringBuffer(StringUtils.concatStrings(this.badRequest.toString(), this.inputRequest.toString())); }} }
private String[] parseCryptRequests() { return this.inputRequest.toString().split("end~"); }
private String decrypt(String request, int key) { this._lastKey = key; char[] _chars = request.toCharArray();
for(int i = 0; i < request.length(); ++i) { _chars[i] = (char)(_chars[i] - (key + 1)); }
return new String(_chars); }
private void sendRequestToManagers(String request) { this.sendCommandToManagers(Commands.decrypt(request)); }
- Assistant
На сервере вам необходимо реализовать метод для расшифровки сообщения, переданного клиентом. Для этого вы можете использовать следующий код:
private String decrypt(String request) { int key = Integer.parseInt(String.valueOf(request.charAt(0))); char[] _chars = request.toCharArray(); for (int i = 0; i < request.length(); i++) { _chars[i] = (char)(_chars[i] - (key + 1)); } return new String(_chars).substring(1); }Вызовите этот метод внутри метода
decryptProtocolпосле проверки условияthis.inputRequest.toString().endsWith("end~"):this.inputRequest = new StringBuffer(this.decrypt(this.inputRequest.toString()));Теперь полученное расшифрованное сообщение может быть отправлено на обработку вашим менеджерам.
Обратите внимание, что на сервере система шифрования не является идентичной клиентской системе. Вместо этого она использует расшифрованный текст, полученный от клиента.