Esempio n. 1
0
        private void createNewFile()
        {
            _currentlyWorking = true;
            var numberOfFiles = _files.Length;

            if (numberOfFiles >= _workOrder.NumberOfFiles)
            {
                _currentlyWorking = false;
                chooseJob();
            }

            var fileName = _workOrder.FilePattern.Replace("*", XkcdPasswordGen.Generate(4));
            var filePath = Path.Combine(_workOrder.FileLocation, fileName);

            using (var fs = File.Create(filePath))
            {
                var info = new UTF8Encoding(true).GetBytes(XkcdPasswordGen.Generate(3));
                fs.Write(info, 0, info.Length);
            }

            getFilesInFolder();

            modifyDataInFile(filePath);
            _currentlyWorking = false;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var fourWordPassword = XkcdPasswordGen.Generate(4);

            Console.WriteLine("4 random words: " + fourWordPassword);

            var dashPassword = XkcdPasswordGen.Generate(4, "-", false, true);

            Console.WriteLine("4 random words separated by a dash: " + dashPassword);

            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsage();
                return;
            }
            if (string.Equals(args[0], "encrypt", StringComparison.OrdinalIgnoreCase))
            {
                if (args.Length == 2)
                {
                    string password = XkcdPasswordGen.Generate(4);
                    var    result   = Encrypt(args[1], password);
                    Console.WriteLine("Password:"******"Encrypted data:");
                    Console.WriteLine(result);
                    return;
                }
                if (args.Length == 3)
                {
                    var result = Encrypt(args[1], args[2]);
                    Console.WriteLine(result);
                    return;
                }
            }
            else if (string.Equals(args[0], "decrypt", StringComparison.OrdinalIgnoreCase))
            {
                if (args.Length == 3)
                {
                    var result = Decrypt(args[1], args[2]);
                    Console.WriteLine(result);
                    return;
                }
            }
            PrintUsage();

            void PrintUsage()
            {
                Console.WriteLine("\nUsage:");
                Console.WriteLine("To encrypt a plaintext string with a generated password:"******"encryptiontool encrypt <plaintext>");
                Console.WriteLine("To encrypt a plaintext string with a specific password:"******"encryptiontool encrypt <plaintext> <password>");
                Console.WriteLine("To decrypt an encrypted string:");
                Console.WriteLine("encryptiontool decrypt <encrypted data> <password>");
            }
        }
        public string GetXKCDPassword(string type)
        {
            Random r    = new Random();
            int    rInt = r.Next(0, 9);

            string password = "";

            if (type == "user")
            {
                password = XkcdPasswordGen.Generate(2, "");
            }
            if (type == "svc")
            {
                password = XkcdPasswordGen.Generate(6, "");
            }
            return(password.First().ToString().ToUpper() + password.Substring(1) + rInt.ToString());
        }
Esempio n. 5
0
        public static string RandomName()
        {
            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            return(textInfo.ToTitleCase($"{XkcdPasswordGen.Generate( 3 )}"));
        }