All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jnngl.server.PacketEncryptor Maven / Gradle / Ivy

The newest version!
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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy