CustomerProvidedKey
Wrapper for an encryption key to be used with client provided key server-side encryption.
            
                using System;
using System.Security.Cryptography;
namespace Azure.Storage.Blobs.Models
{
    public readonly struct CustomerProvidedKey : IEquatable<CustomerProvidedKey>
    {
        public string EncryptionKey { get; }
        public string EncryptionKeyHash { get; }
        public EncryptionAlgorithmType EncryptionAlgorithm { get; }
        public CustomerProvidedKey(string key)
        {
            EncryptionKey = key;
            EncryptionAlgorithm = EncryptionAlgorithmType.Aes256;
            using (SHA256 sHA = SHA256.Create()) {
                byte[] inArray = sHA.ComputeHash(Convert.FromBase64String(key));
                EncryptionKeyHash = Convert.ToBase64String(inArray);
            }
        }
        public CustomerProvidedKey(byte[] key)
        {
            this = new CustomerProvidedKey(Convert.ToBase64String(key));
        }
        public override bool Equals(object obj)
        {
            if (obj is CustomerProvidedKey) {
                CustomerProvidedKey other = (CustomerProvidedKey)obj;
                return Equals(other);
            }
            return false;
        }
        public override int GetHashCode()
        {
            return EncryptionKey.GetHashCode() ^ EncryptionKeyHash.GetHashCode() ^ EncryptionAlgorithm.GetHashCode();
        }
        public static bool operator ==(CustomerProvidedKey left, CustomerProvidedKey right)
        {
            return left.Equals(right);
        }
        public static bool operator !=(CustomerProvidedKey left, CustomerProvidedKey right)
        {
            return !(left == right);
        }
        public bool Equals(CustomerProvidedKey other)
        {
            if (EncryptionKey == other.EncryptionKey && EncryptionKeyHash == other.EncryptionKeyHash)
                return EncryptionAlgorithm == other.EncryptionAlgorithm;
            return false;
        }
        public override string ToString()
        {
            return string.Format("[{0}:{1}={2};{3}={4};{5}={6}]", "CustomerProvidedKey", "EncryptionKey", EncryptionKey, "EncryptionKeyHash", EncryptionKeyHash, "EncryptionAlgorithm", EncryptionAlgorithm);
        }
    }
}