package common.network;

import javax.crypto.Cipher;
import javax.crypto.ShortBufferException;

import common.net.buffer.ByteBuf;
import common.net.channel.ChannelHandlerContext;
import common.net.handler.codec.MessageToByteEncoder;

public class EncryptionEncoder extends MessageToByteEncoder<ByteBuf> {
	private final EncryptionCodec codec;

	public EncryptionEncoder(Cipher cipher) {
		this.codec = new EncryptionCodec(cipher);
	}

	protected void encode(ChannelHandlerContext context, ByteBuf buffer, ByteBuf output) throws ShortBufferException, Exception {
		this.codec.cipher(buffer, output);
	}
}
