minecraft-src/net/minecraft/network/CipherEncoder.java
2025-07-04 01:41:11 +03:00

23 lines
624 B
Java

package net.minecraft.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import javax.crypto.Cipher;
/**
* Channel handler that handles protocol encryption.
*
* @see Connection#setEncryptionKey
*/
public class CipherEncoder extends MessageToByteEncoder<ByteBuf> {
private final CipherBase cipher;
public CipherEncoder(Cipher cipher) {
this.cipher = new CipherBase(cipher);
}
protected void encode(ChannelHandlerContext context, ByteBuf message, ByteBuf out) throws Exception {
this.cipher.encipher(message, out);
}
}