org.rx.net.AESCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rxlib Show documentation
Show all versions of rxlib Show documentation
A set of utilities for Java
package org.rx.net;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.MessageToMessageCodec;
import lombok.RequiredArgsConstructor;
import org.rx.codec.AESUtil;
import org.rx.core.Constants;
import java.util.List;
@RequiredArgsConstructor
public class AESCodec extends MessageToMessageCodec {
final byte[] key;
public ChannelHandler[] channelHandlers() {
return new ChannelHandler[]{
new LengthFieldBasedFrameDecoder(Constants.MAX_HEAP_BUF_SIZE, 0, 4, 0, 4),
Sockets.INT_LENGTH_PREPENDER, this
};
}
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List