com.jnngl.server.PacketEncryptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of totalcomputers Show documentation
Show all versions of totalcomputers Show documentation
Computers in vanilla Minecraft | TotalOS SDK
package com.jnngl.server;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
public class PacketEncryptor extends MessageToByteEncoder {
private final Encryption encryption;
public PacketEncryptor(Encryption encryption) {
this.encryption = encryption;
}
@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
byte[] data = new byte[msg.readableBytes()];
msg.readBytes(data);
out.writeBytes(encryption.encryptAES(data));
}
}