Example #1
0
        public static void Read(MySafe safe, string fileName)
        {
            string encrypted = File.ReadAllText(fileName);
            string decrypted = safe.Decrypt(encrypted);

            WriteLine(decrypted);
        }
Example #2
0
        static void Main(string[] args)
        {
            if (args.Length != 2 || args.Intersect(options).Count() != 1)
            {
                ShowUsage();
                return;
            }
            string fileName = args[1];

            MySafe safe = InitProtection();


            switch (args[0])
            {
            case writeOption:
                Write(safe, fileName);
                break;

            case readOption:
                Read(safe, fileName);
                break;

            default:
                ShowUsage();
                break;
            }
        }
 public static void Write(MySafe safe, string fileName)
 {
     WriteLine("enter content to write:");
     string content = ReadLine();
     string encrypted = safe.Encrypt(content);
     File.WriteAllText(fileName, encrypted);
     WriteLine($"content written to {fileName}");
 }
Example #4
0
        public static void Write(MySafe safe, string fileName)
        {
            WriteLine("enter content to write:");
            string content   = ReadLine();
            string encrypted = safe.Encrypt(content);

            File.WriteAllText(fileName, encrypted);
            WriteLine($"content written to {fileName}");
        }
 public static void Read(MySafe safe, string fileName)
 {
     string encrypted = File.ReadAllText(fileName);
     string decrypted = safe.Decrypt(encrypted);
     WriteLine(decrypted);
 }