code: private ByteBuffer signPacket(ByteBuffer packet) {
          final byte[] signature = sign(password, (ByteBuffer) ByteBuffer.allocate(packet.remaining() + username.length)
                  .put(username)
                  .put(packet)
                  .flip());
          return (ByteBuffer) ByteBuffer.allocate(BUFFER_SIZE)
                  .putShort((short) TYPE_SIGN_SHA256)
                  .putShort((short) (username.length + SIGNATURE_LEN))
                  .put(signature)
                  .put(username)
                  .put((ByteBuffer) packet.flip())
                  .flip();
      }
docs: Signs the provided packet, so a CollectD server can verify that its authenticity.
  Wire format:
  <pre>
  +-------------------------------+-------------------------------+
  ! Type (0x0200)                 ! Length                        !
  +-------------------------------+-------------------------------+
  ! Signature (SHA2(username + packet))                           \
  +-------------------------------+-------------------------------+
  ! Username                      ! Packet                        \
  +---------------------------------------------------------------+
  </pre>
  
  @see <a href="https://collectd.org/wiki/index.php/Binary_protocol#Signature_part">
  Binary protocol - CollectD | Signature part</a>