code: public void encrypt(ByteBuffer src) throws SSLException {
          if (!handshakeComplete) {
              throw new IllegalStateException();
          }
  
          if (!src.hasRemaining()) {
              if (outNetBuffer == null) {
                  outNetBuffer = emptyBuffer;
              }
              return;
          }
  
          createOutNetBuffer(src.remaining());
  
          // Loop until there is no more data in src
          while (src.hasRemaining()) {
  
              SSLEngineResult result = sslEngine.wrap(src, outNetBuffer.buf());
              if (result.getStatus() == SSLEngineResult.Status.OK) {
                  if (result.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_TASK) {
                      doTasks();
                  }
              } else if (result.getStatus() == SSLEngineResult.Status.BUFFER_OVERFLOW) {
                  outNetBuffer.capacity(outNetBuffer.capacity() << 1);
                  outNetBuffer.limit(outNetBuffer.capacity());
              } else {
                  throw new SSLException("SSLEngine error during encrypt: "
                          + result.getStatus() + " src: " + src
                          + "outNetBuffer: " + outNetBuffer);
              }
          }
  
          outNetBuffer.flip();
      }
docs: Encrypt provided buffer. Encrypted data returned by getOutNetBuffer().
  
  @param src data to encrypt
  @throws SSLException on errors