code: public final byte[] encryptString(SecretKey sharedKey, String string) {
          logger.entry();
          try (ByteArrayInputStream input = new ByteArrayInputStream(string.getBytes("UTF-8"));
                  ByteArrayOutputStream output = new ByteArrayOutputStream()) {
              encryptStream(sharedKey, input, output);
              output.flush();
              byte[] encryptedString = output.toByteArray();
              logger.exit();
              return encryptedString;
          } catch (IOException e) {
              // should never happen!
              RuntimeException exception = new RuntimeException("An unexpected exception occured while trying to encrypt a string.", e);
              logger.error(exception.toString());
              throw exception;
          }
      }
docs: This method encrypts a string using a shared key.
  
  @param sharedKey The shared key used for the encryption.
  @param string The string to be encrypted.
  @return The encrypted string.