Description
The encrypt function call output.write without loop which lead to data loss when creating the output encryption stream with a SocketChannel and works in non-block mode.
As suggested, it should be call as following way:
while(buf.hasRemaining()) {
channel.write(buf);
}