| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | |
|
| | 7 | | namespace Azure.Storage.Cryptography.Models |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Specifies the encryption algorithm used to encrypt and decrypt a blob. |
| | 11 | | /// </summary> |
| | 12 | | internal readonly struct ClientSideEncryptionAlgorithm |
| | 13 | | { |
| | 14 | | internal const string AesCbc256Value = "AES_CBC_256"; |
| | 15 | |
|
| | 16 | | private readonly string _value; |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Initializes a new instance of the <see cref="ClientSideEncryptionAlgorithm"/> structure. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="value">The string value of the instance.</param> |
| | 22 | | public ClientSideEncryptionAlgorithm(string value) |
| | 23 | | { |
| 0 | 24 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// AES-CBC using a 256 bit key. |
| | 29 | | /// </summary> |
| 0 | 30 | | public static ClientSideEncryptionAlgorithm AesCbc256 { get; } = new ClientSideEncryptionAlgorithm(AesCbc256Valu |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Determines if two <see cref="ClientSideEncryptionAlgorithm"/> values are the same. |
| | 34 | | /// </summary> |
| | 35 | | /// <param name="left">The first <see cref="ClientSideEncryptionAlgorithm"/> to compare.</param> |
| | 36 | | /// <param name="right">The second <see cref="ClientSideEncryptionAlgorithm"/> to compare.</param> |
| | 37 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| 0 | 38 | | public static bool operator ==(ClientSideEncryptionAlgorithm left, ClientSideEncryptionAlgorithm right) => left. |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Determines if two <see cref="ClientSideEncryptionAlgorithm"/> values are different. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="left">The first <see cref="ClientSideEncryptionAlgorithm"/> to compare.</param> |
| | 44 | | /// <param name="right">The second <see cref="ClientSideEncryptionAlgorithm"/> to compare.</param> |
| | 45 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| 0 | 46 | | public static bool operator !=(ClientSideEncryptionAlgorithm left, ClientSideEncryptionAlgorithm right) => !left |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Converts a string to a <see cref="ClientSideEncryptionAlgorithm"/>. |
| | 50 | | /// </summary> |
| | 51 | | /// <param name="value">The string value to convert.</param> |
| 0 | 52 | | public static implicit operator ClientSideEncryptionAlgorithm(string value) => new ClientSideEncryptionAlgorithm |
| | 53 | |
|
| | 54 | | /// <inheritdoc/> |
| | 55 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 56 | | public override bool Equals(object obj) => obj is ClientSideEncryptionAlgorithm other && Equals(other); |
| | 57 | |
|
| | 58 | | /// <inheritdoc/> |
| 0 | 59 | | public bool Equals(ClientSideEncryptionAlgorithm other) => string.Equals(_value, other._value, StringComparison. |
| | 60 | |
|
| | 61 | | /// <inheritdoc/> |
| | 62 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 63 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | 64 | |
|
| | 65 | | /// <inheritdoc/> |
| 0 | 66 | | public override string ToString() => _value; |
| | 67 | | } |
| | 68 | | } |