public void CreateWiper_InstantiateNewEnhanced_Pass()
        {
            HMG_IS5WiperFactory fact = new HMG_IS5WiperFactory();
            HMG_IS5Wiper wiper = (HMG_IS5Wiper)fact.CreateWiper(true);

            Assert.IsTrue(wiper.Enhanced);
        }
        public void CreateWiper_InstantiateNew_Pass()
        {
            HMG_IS5WiperFactory fact = new HMG_IS5WiperFactory();
            HMG_IS5Wiper wiper = (HMG_IS5Wiper)fact.CreateWiper(); 

            Assert.IsNotNull(wiper);
        }
        public void WipeStream_WipeRandomStream_Pass()
        {
            MemoryStream stream = new MemoryStream();

            for (int i = 0; i < 100; i++)
                stream.WriteByte(0x1F);

            var fact = new HMG_IS5WiperFactory();
            HMG_IS5Wiper wiper = (HMG_IS5Wiper)fact.CreateWiper(true);

            wiper.WipeStream(stream);

            Assert.IsTrue(stream.Length == 0);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                string choice = "";
                string mainCmd = "";
                do
                {
                    Console.Write("$Cipha: ");
                    choice = Console.ReadLine();
                    string[] cmds = choice.Split(' ');
                    mainCmd = choice.Contains(" ") ? choice.Substring(0, choice.IndexOf(' ')) : choice;

                    switch (mainCmd)
                    {
                        case "lst":
                            string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                            Console.WriteLine(path);
                            break;
                        case "enc":
                            if (cmds.Length != 4)
                            {
                                Console.WriteLine("Insufficient parameters for 'dec'. Use: dec <plainFile> <encryptedFile> <password>");
                                return;
                            }
                            string from = cmds[1];
                            string to = cmds[2];
                            string pw = cmds[3];

                            if (File.Exists(from))
                            {
                                File.WriteAllBytes(to, new GenericSymmetricCipher<RijndaelManaged>().Encrypt(File.ReadAllBytes(from), pw, "abcdefghij;;;"));
                            }

                            break;
                        case "dec":
                            if (cmds.Length != 4)
                            {
                                Console.WriteLine("Insufficient parameters for 'dec'. Use: dec <encryptedFile> <normalFile> <password>");
                                return;
                            }

                            string from2 = cmds[1];
                            string to2 = cmds[2];
                            string pw2 = cmds[3];

                            break;
                        case "rm":
                            string input = cmds[1];
                            Wiper dest = new HMG_IS5WiperFactory().CreateWiper();
                            dest.WipeFile(input);
                            break;
                        case "quit":
                        case "q":
                            break;
                        default:
                            Console.WriteLine("Command not recognized.");
                            break;
                    }
                } while (mainCmd != "q" && mainCmd != "quit");
            }
        }