public static string ToRawValue()

in Vault/Explorer/ContentType.cs [168:205]


        public static string ToRawValue(this ContentType contentType, string value)
        {
            if (value == null) return null;

            switch (contentType)
            {
                case ContentType.None:
                case ContentType.Text:
                case ContentType.Csv:
                case ContentType.Tsv:
                case ContentType.Xml:
                case ContentType.Json:
                case ContentType.Certificate:
                case ContentType.Pkcs12:
                case ContentType.KeyVaultSecret:
                case ContentType.KeyVaultCertificate:
                case ContentType.KeyVaultLink:
                    return value;
                case ContentType.Pkcs12Base64:
                case ContentType.Base64:
                    return Convert.ToBase64String(Encoding.UTF8.GetBytes(value));
                case ContentType.JsonGZipBase64:
                    // Compress and Encode (base64) the secret value
                    using (var input = new MemoryStream(Encoding.UTF8.GetBytes(value)))
                    {
                        using (var output = new MemoryStream())
                        {
                            using (var gz = new GZipStream(output, CompressionMode.Compress, true))
                            {
                                input.CopyTo(gz);
                            }
                            return Convert.ToBase64String(output.ToArray());
                        }
                    }
                default:
                    throw new ArgumentException($"Invalid ContentType {contentType}");
            }
        }