5.0.0 (latest) 4.16.0 4.15.0 4.14.0 4.13.0 4.11.0 4.10.0 4.9.0 4.8.0 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.7.0 3.6.0 3.5.0 3.4.0

    public sealed class EncryptionKey : IEquatable<EncryptionKey>

Reference documentation and code samples for the Google Cloud Storage v1 API class EncryptionKey.

An AES-256 key passed to the Google Cloud Storage servers via headers to allow objects to be encrypted at
rest using a client-supplied key rather than a server-supplied default key. An alternative to
customer-supplied encryption keys is to use customer-managed encryption keys, via Cloud KMS.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> EncryptionKey

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[EncryptionKey](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey)

## Inherited Members

[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Storage.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1)

## Assembly

Google.Cloud.Storage.V1.dll

## Properties

### Base64Hash

    public string Base64Hash { get; }

The base64 representation of the SHA-256 hash of the key. This will always be 45 characters long,
or `null` for [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey#Google_Cloud_Storage_V1_EncryptionKey_None).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### Base64Key

    public string Base64Key { get; }

The base64 representation of the key. This will always be 45 characters long,
or `null` for [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey#Google_Cloud_Storage_V1_EncryptionKey_None).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### None

    public static EncryptionKey None { get; }

A "don't encrypt" key, used in call-specific options to indicate that a particular request should
not use encryption even if the client has a default encryption key.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey` |   |

## Methods

### Create(byte\[\])

    public static EncryptionKey Create(byte[] key)

Creates an encryption key from the specified raw bytes.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `System.Byte` The raw key data; must be non-null and 32 bytes long. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey` | An [EncryptionKey](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey) based on `key`. |

### Generate()

    public static EncryptionKey Generate()

Generates a random encryption key using [RandomNumberGenerator](https://learn.microsoft.com/dotnet/api/system.security.cryptography.randomnumbergenerator).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey` | A generated encryption key. |

### GetHashCode()

    public override int GetHashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

**Overrides** [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)

### ModifyRequest(HttpRequestMessage)

    public void ModifyRequest(HttpRequestMessage request)

Adds encryption headers to the specified request, unless this key is [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey#Google_Cloud_Storage_V1_EncryptionKey_None),

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage` The request to modify. Must not be null. |