public static SecretsData FromPassword(string password)
        {
            var secret     = new EncryptionSecret(DefaultVersion, Encoding.UTF8.GetBytes(password));
            var secretKeys = new List <Secret> {
                secret
            };

            return(new SecretsData(secretKeys, secret));
        }
        public static SecretsData FromJson(string secretsDataJson)
        {
            try
            {
                var    secretList           = new List <Secret>();
                var    dataFromJson         = JsonConvert.DeserializeObject <SecretDataFromJson>(secretsDataJson, s_jsonSettings);
                var    currentSecretVersion = dataFromJson.CurrentVersion;
                Secret currentSecret        = null;
                foreach (var secret in dataFromJson.Secrets)
                {
                    s_helper.Check <StorageClientException>(secret == null,
                                                            Messages.SecretsDataGenerator.s_errNullSecret);
                    var invalidOptions = secret.IsKey && secret.IsForCustomEncryption;
                    s_helper.Check <StorageClientException>(invalidOptions, Messages.SecretsDataGenerator.s_errOption);
                    Secret newSecret;
                    if (secret.IsForCustomEncryption)
                    {
                        newSecret = new CustomEncryptionKey(secret.Version, Convert.FromBase64String(secret.Secret));
                    }
                    else if (secret.IsKey)
                    {
                        newSecret = new EncryptionKey(secret.Version, Convert.FromBase64String(secret.Secret));
                    }
                    else
                    {
                        newSecret = new EncryptionSecret(secret.Version, Encoding.UTF8.GetBytes(secret.Secret));
                    }

                    secretList.Add(newSecret);

                    if (secret.Version == currentSecretVersion)
                    {
                        currentSecret = newSecret;
                    }
                }

                return(new SecretsData(secretList, currentSecret));
            }
            catch (System.Exception innerException)
            {
                s_log.Error(innerException);
                throw new StorageClientException(Messages.SecretsDataGenerator.s_errWrongJson, innerException);
            }
        }