コード例 #1
0
        public void program(string input_filename, bool encrypt, int encryptionType, string output_file, string key)
        {
            if (File.Exists(input_filename))
            {
                string[] file_ext = input_filename.Split('.');
                file_ext[1] = file_ext[1].ToLower();

                CSFile test;
                if (file_ext[1] == "doc" || file_ext[1] == "docx" || file_ext[1] == "txt" || file_ext[1] == "xls" ||
                    file_ext[1] == "xlsx")
                {
                    // Documents
                    test = new CSDocument();
                    test.import(encryptionType, input_filename);
                    test.setKey(key);

                    if (encrypt == true)
                    {
                        test.encrypt(encryptionType);
                    }
                    else
                    {
                        test.decrypt(encryptionType);
                    }

                    test.export(encrypt, encryptionType, output_file);
                }
                else if (file_ext[1] == "png" || file_ext[1] == "bmp" || file_ext[1] == "jpg" || file_ext[1] == "jpeg")
                {
                    // Images
                    test = new CSImage();
                    test.import(encryptionType, input_filename);
                    test.setKey(key);

                    if (encrypt == true)
                    {
                        test.encrypt(encryptionType);
                    }
                    else
                    {
                        test.decrypt(encryptionType);
                    }

                    test.export(encrypt, encryptionType, output_file);
                }
            }
        }
コード例 #2
0
        private static void ProgMain(string[] args)
        {
            ////////////////////////////////////////////////////////////////
            /// Jarid command line arguments ///////////////////////////////
            ////////////////////////////////////////////////////////////////
            int    encryptionType = 3;
            bool   encrypt        = true;
            string input_filename = "C:/Users/aalirehman/Desktop/test2.png";
            string output_file    = "C:/Users/aalirehman/Desktop/test3.png";
            string key            = "Thisis my keyasdfasfakfasdfjdskfjsd;kfjabc123";

            ////////////////////////////////////////////////////////////////


            /****************************************
            * DO NOT TOUCH
            ****************************************/

            if (File.Exists(input_filename))
            {
                string[] file_ext = input_filename.Split('.');
                file_ext[1] = file_ext[1].ToLower();

                CSFile test;
                if (file_ext[1] == "doc" || file_ext[1] == "docx" || file_ext[1] == "txt" || file_ext[1] == "xls" ||
                    file_ext[1] == "xlsx")
                {
                    // Documents
                    test = new CSDocument();

                    test.import(input_filename);
                    test.setKey(key);

                    if (encrypt == true)
                    {
                        test.encrypt(encryptionType);
                    }
                    else
                    {
                        test.decrypt(encryptionType);
                    }

                    test.export(output_file);
                }
                else if (file_ext[1] == "png" || file_ext[1] == "bmp" || file_ext[1] == "jpg" || file_ext[1] == "jpeg")
                {
                    // Images
                    test = new CSImage();

                    test.import(input_filename);
                    test.setKey(key);

                    if (encrypt == true)
                    {
                        test.encrypt(encryptionType);
                    }
                    else
                    {
                        test.decrypt(encryptionType);
                    }

                    test.export(output_file);
                }
                else if (file_ext[1] == "mp4")
                {
                    // Videos
                }
                else
                {
                }
            }
        }