/// <summary>
        /// Encrypts a string and returns it as a binary BinHex or Base64 string
        /// </summary>
        /// <param name="dataToProtect"></param>
        /// <param name="stringEncodingMode"></param>
        /// <returns></returns>
        public static string Protect(string dataToProtect,
                                     DataProtectionStringEncodingModes stringEncodingMode = DataProtectionStringEncodingModes.Base64)
        {
            var dataProtector = GetDataProtector();

            byte[] protectedBytes = Encoding.UTF8.GetBytes(dataToProtect);
            byte[] plainBytes     = dataProtector.Protect(protectedBytes);

            if (stringEncodingMode == DataProtectionStringEncodingModes.BinHex)
            {
                return(StringUtils.BinaryToBinHex(plainBytes));
            }

            return(Convert.ToBase64String(plainBytes));
        }
        /// <summary>
        /// Decrypts a previously protected strings from BinHex or Base64 binary data
        /// and returns the orignal string data.
        /// </summary>
        /// <param name="protectedStringData"></param>
        /// <param name="stringEncodingMode"></param>
        /// <returns></returns>
        public static string UnProtect(string protectedStringData,
                                       DataProtectionStringEncodingModes stringEncodingMode = DataProtectionStringEncodingModes.Base64)
        {
            var protector = GetDataProtector();

            byte[] protectedBytes;
            if (stringEncodingMode == DataProtectionStringEncodingModes.BinHex)
            {
                protectedBytes = StringUtils.BinHexToBinary(protectedStringData);
            }
            else
            {
                protectedBytes = Convert.FromBase64String(protectedStringData);
            }

            byte[] plainBytes = protector.Unprotect(protectedBytes);
            return(Encoding.UTF8.GetString(plainBytes));
        }