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; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.cloud.kms.v1.EncryptResponse buildPartial() { com.google.cloud.kms.v1.EncryptResponse result = new com.google.cloud.kms.v1.EncryptResponse(this); result.name_ = name_; result.ciphertext_ = ciphertext_; onBuilt(); return result; }
@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; }
/** * * * <pre> * The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] used in encryption. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
@java.lang.Override public com.google.cloud.kms.v1.EncryptResponse getDefaultInstanceForType() { return com.google.cloud.kms.v1.EncryptResponse.getDefaultInstance(); }
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
/** * 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 void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } if (!ciphertext_.isEmpty()) { output.writeBytes(2, ciphertext_); } unknownFields.writeTo(output); }
@java.lang.Override public com.google.cloud.kms.v1.EncryptResponse build() { com.google.cloud.kms.v1.EncryptResponse result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
/** * * * <pre> * The encrypted data. * </pre> * * <code>bytes ciphertext = 2;</code> */ public Builder clearCiphertext() { ciphertext_ = getDefaultInstance().getCiphertext(); onChanged(); return this; }
@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 resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] used in encryption. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
@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; }
.setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.kms.v1.EncryptResponse.getDefaultInstance())) .setSchemaDescriptor( new KeyManagementServiceMethodDescriptorSupplier("Encrypt"))
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); } if (!ciphertext_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, ciphertext_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public com.google.cloud.kms.v1.EncryptResponse build() { com.google.cloud.kms.v1.EncryptResponse result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }