Example #1
0
        public void CreateFile(string filename, string text, string parent)
        {
            try
            {
                try
                {
                    string path = @"~\..\..\..\..\Service\bin\Debug\";
                    factory.CreateFile(path + "encryptedFile_" + filename, text, parent);
                    if (File.Exists(path + "key.txt"))
                    {
                        string key = Key.LoadKey(path + "key.txt");
                        AES.Decrypt(path + "encryptedFile_" + filename + ".txt", path + filename, key);

                        FilesAndFolders.MoveFile(filename, parent);
                    }
                }
                catch (SecurityAccessDeniedException e)
                {
                    Console.WriteLine("Error 1, security access denied exception: {0}", e.Message);
                }
                catch (FaultException e)
                {
                    Console.WriteLine("Error 2, fault exception: {0}", e.Message);
                }
            }
            catch (SecurityException e)
            {
                Console.WriteLine("Error 3 while tryin to CreateFile, security exception: {0}", e.Message);
            }
        }
Example #2
0
 public static void Initialize()
 {
     VERSION     = AES.Decrypt(VERSION, ENCRYPTIONKEY);
     HOST        = AES.Decrypt(HOST, ENCRYPTIONKEY);
     PASSWORD    = AES.Decrypt(PASSWORD, ENCRYPTIONKEY);
     SUBFOLDER   = AES.Decrypt(SUBFOLDER, ENCRYPTIONKEY);
     INSTALLNAME = AES.Decrypt(INSTALLNAME, ENCRYPTIONKEY);
     MUTEX       = AES.Decrypt(MUTEX, ENCRYPTIONKEY);
     STARTUPKEY  = AES.Decrypt(STARTUPKEY, ENCRYPTIONKEY);
 }
Example #3
0
        public void ReadFile(string filename)
        {
            try
            {
                factory.ReadFile(filename);

                string path       = @"~\..\..\..\..\Service\bin\Debug\";
                string filetoread = path + filename + "_encryptedToRead.txt";

                if (!File.Exists(filetoread))
                {
                    Console.WriteLine("Ne postoji {0}", filename);
                }
                else
                {
                    string key = path + "key.txt";
                    if (File.Exists(key))
                    {
                        AES.Decrypt(filetoread, path + filename + "_decryptedToRead", Key.LoadKey(key));
                    }

                    Console.WriteLine("Dobio sam enkriptovan fajl:");
                    Console.WriteLine(ASCIIEncoding.ASCII.GetString(File.ReadAllBytes(filetoread)));
                    Console.WriteLine("Posle dekripcije, imam sadržaj fajla {0} : ", filename);
                    Console.WriteLine(ASCIIEncoding.ASCII.GetString(File.ReadAllBytes(path + filename + "_decryptedToRead.txt")));

                    File.Delete(path + filename + "_decryptedToRead.txt");
                    File.Delete(filetoread);
                    File.Delete(key);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while trying to read file {0} : {1}", filename, e.Message);
            }
        }