@Override
  public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
      throws GeneralSecurityException {
    try {
      EncryptRequest request =
          new EncryptRequest()
              .encodePlaintext(plaintext)
              .encodeAdditionalAuthenticatedData(associatedData);
      EncryptResponse response =
          this.kmsClient
              .projects()
              .locations()
              .keyRings()
              .cryptoKeys()
              .encrypt(this.keyName, request)
              .execute();
      return toNonNullableByteArray(response.decodeCiphertext());
    } catch (IOException e) {
      throw new GeneralSecurityException("encryption failed", e);
    }
  }
An HTTP-based client to communicate with Google Cloud KMS.
java_src/src/main/java/com/google/crypto/tink/integration/gcpkms/GcpKmsAead.java