Example #1
0
        static void Main(string[] args)
        {
            protector = new ProtectionNonDi(new ProtectionConstants());
            //ProtectConfigurationFile("data/appsettings.json", "data/appsettings.json");
            //UnProtectConfigurationFile("data/appsettings.json", "data/appsettings.json");
            //UnProtectConfigurationFile("protectedConfiguration.json", "unprotectedConfiguration.json");

            ReadAndWriteValueFromJsonFile("data/appsettings.json", "");
        }
Example #2
0
        private static void WriteProtectedResultToFile()
        {
            var protector = new ProtectionNonDi(new ProtectionConstants());

            var stringToProtect = "holaQueTal";
            var protectedString = protector.Protect(stringToProtect);

            Console.WriteLine($"String to protect: {stringToProtect}");
            Console.WriteLine($"Protected string: {protectedString}");

            WriteToFile("resultat.txt", stringToProtect, true);
        }
Example #3
0
        private static void UnProtectConfigurationFile(string inputFileName, string outputFileName)
        {
            var    protector = new ProtectionNonDi(new ProtectionConstants());
            string konfJson;

            var    konfStr = ReadFileToString(inputFileName);
            var    konf    = JsonConvert.DeserializeObject <dynamic>(konfStr);
            string value   = konf["AzureAd"]["Instance"];

            konf["AzureAd"]["Instance"] = protector.Unprotect(value);

            konfJson = JsonConvert.SerializeObject(konf, Formatting.Indented);

            Console.WriteLine(konfJson);
            WriteToFile(outputFileName, konfJson);
        }