Skip to content

Commit

Permalink
don't use specific charset during encryption codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
Quackster committed Jul 13, 2024
1 parent c5490b8 commit d2c648d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
byte[] tHeaderMsg = new byte[6];
buffer.readBytes(tHeaderMsg);

tHeader = new String(tHeaderMsg, StringUtil.getCharset());
tHeader = new String(tHeaderMsg);
tHeader = this.pHeaderDecoder.kg4R6Jo5xjlqtFGs1klMrK4ZTzb3R(tHeader);

int tByte1 = ((int) tHeader.charAt(3)) & 63;
Expand All @@ -60,14 +60,14 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
byte[] tBodyMsg = new byte[pMsgSize];
buffer.readBytes(tBodyMsg);

tBody = new String(tBodyMsg, StringUtil.getCharset());
tBody = new String(tBodyMsg);
tBody = this.pDecoder.kg4R6Jo5xjlqtFGs1klMrK4ZTzb3R(tBody);
tBody = NettyPlayerNetwork.removePadding(tBody, player.getNetwork().getTx() % 5);

ByteBuf result = Unpooled.buffer();

result.writeBytes(Base64Encoding.encode(tBody.length(), 3));
result.writeBytes(tBody.getBytes(StringUtil.getCharset()));
result.writeBytes(tBody.getBytes());

out.add(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.slf4j.LoggerFactory;

import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

Expand All @@ -35,7 +36,10 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
player.getNetwork().getRx()
));

String tOriginalMsg = buffer.toString(StringUtil.getCharset());
byte[] tOriginalMsgBytes = new byte[buffer.readableBytes()];
buffer.readBytes(tOriginalMsgBytes);

String tOriginalMsg = new String(tOriginalMsgBytes);

String tHeader;
String tMsg;
Expand All @@ -53,8 +57,8 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou

var tEncryptedMsg = Unpooled.buffer();

tEncryptedMsg.writeBytes(tHeader.getBytes(StringUtil.getCharset()));
tEncryptedMsg.writeBytes(tMsg.getBytes(StringUtil.getCharset()));
tEncryptedMsg.writeBytes(tHeader.getBytes());
tEncryptedMsg.writeBytes(tMsg.getBytes());

out.add(tEncryptedMsg);
}
Expand Down

0 comments on commit d2c648d

Please sign in to comment.