@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.EncryptResponse)) { return super.equals(obj); } com.google.cloud.kms.v1.EncryptResponse other = (com.google.cloud.kms.v1.EncryptResponse) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getCiphertext().equals(other.getCiphertext()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + CIPHERTEXT_FIELD_NUMBER; hash = (53 * hash) + getCiphertext().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The encrypted data. * </pre> * * <code>bytes ciphertext = 2;</code> */ public Builder clearCiphertext() { ciphertext_ = getDefaultInstance().getCiphertext(); onChanged(); return this; }
public Builder mergeFrom(com.google.cloud.kms.v1.EncryptResponse other) { if (other == com.google.cloud.kms.v1.EncryptResponse.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getCiphertext() != com.google.protobuf.ByteString.EMPTY) { setCiphertext(other.getCiphertext()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * Encrypts the given plaintext using the specified crypto key. */ public static byte[] encrypt( String projectId, String locationId, String keyRingId, String cryptoKeyId, byte[] plaintext) throws IOException { // Create the KeyManagementServiceClient using try-with-resources to manage client cleanup. try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); // Encrypt the plaintext with Cloud KMS. EncryptResponse response = client.encrypt(resourceName, ByteString.copyFrom(plaintext)); // Extract the ciphertext from the response. return response.getCiphertext().toByteArray(); } } // [END kms_encrypt]
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.EncryptResponse)) { return super.equals(obj); } com.google.cloud.kms.v1.EncryptResponse other = (com.google.cloud.kms.v1.EncryptResponse) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getCiphertext().equals(other.getCiphertext()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + CIPHERTEXT_FIELD_NUMBER; hash = (53 * hash) + getCiphertext().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The encrypted data. * </pre> * * <code>bytes ciphertext = 2;</code> */ public Builder clearCiphertext() { ciphertext_ = getDefaultInstance().getCiphertext(); onChanged(); return this; }
public Builder mergeFrom(com.google.cloud.kms.v1.EncryptResponse other) { if (other == com.google.cloud.kms.v1.EncryptResponse.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getCiphertext() != com.google.protobuf.ByteString.EMPTY) { setCiphertext(other.getCiphertext()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }