public static string New2FA(string email) { string tfacode = CryptoRand.Random2faString(); TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); var setupInfo = tfa.GenerateSetupCode("PASSCYPHER", email, tfacode, 300, 300); Console.WriteLine("/n" + setupInfo.ManualEntryKey); Console.Write("Press ENTER: "); Console.ReadLine(); return(tfacode); }
public static void Passwordgen() { string tag = CryptoRand.RandomString(20); Console.WriteLine("Please enter a User name for the password"); Format.Dash(); string username = Console.ReadLine(); Format.Dash(); Console.WriteLine("Please name the service that uses the UN/P"); Format.Dash(); string service = Console.ReadLine(); string plaintext = service + ": " + username + " " + tag; string encryptedstring = StringCipher.RjndlEncrypt(plaintext, SessionParameters.Pass); StreamWriter sw = null; try { sw = new StreamWriter(SessionParameters.Keypath, true); sw.WriteLine(encryptedstring); //sw.Close(); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } finally { sw.Close(); } Format.Dash(); Console.WriteLine("Your password string is:"); Format.Dash(); Console.WriteLine(tag); Console.Write("Press ENTER: "); Console.ReadLine(); return; }
private static string[] Paths = new string[3]; /*{ get; set; }*/ internal static void NewUser() { Format.Clear(); Console.WriteLine("PASSCYPHER makes use of Google Authenticate two-factor Authentication"); Format.Dash(); while (true) { Console.WriteLine("Enter a user name"); string Username = Console.ReadLine(); string Userpath = Username; Userpath = Path.Combine("Users", Userpath); if (!Directory.Exists(Userpath)) { Directory.CreateDirectory(Userpath); // creates a seperate directory for files Paths[0] = Path.Combine(Userpath, Username + "_Master.txt"); // path stores master key for user Paths[1] = Path.Combine(Userpath, Username + "_Keys.txt"); // path stores passwords Paths[2] = Path.Combine(Userpath, Username + "_Config.txt"); // path stores misc data such as 2FA key and email foreach (string path in Paths) { File.Create(path).Close(); } break; } else { Console.WriteLine("User name taken\nPlease pick a new name"); } } Console.WriteLine("Enter an Email Address"); string email = Console.ReadLine(); string password = PasswordStrength(); string masterkey = CryptoRand.RandomString(40); string securekey = _2FA.New2FA(email); Encrypt(securekey, masterkey, Paths[2]); Encrypt(email, masterkey, Paths[2]); Encrypt(masterkey, password, Paths[0]); }
public static void Mainmenu() { string choice = ""; while (true) { MenuContext(); try { choice = Reader.ReadLine(120000); } catch (TimeoutException) { Format.Clear(); Console.WriteLine("Session has Timed Out"); Console.ReadLine(); Format.Dash(); return; } switch (choice) { case "test": Console.WriteLine(CryptoRand.RandomString(50)); Console.ReadLine(); break; case "new": Format.Clear(); ReadWrite.Passwordgen(); break; case "load": Load(); break; case "Synq": Format.Clear(); Filereceiver.SendFile(); break; case "Update": Format.Clear(); Filereceiver.RecFile(); break; case "lock": Format.Clear(); return; case "help": Help.GetHelp(); Format.Clear(); break; case "exit": Environment.Exit(0); break; default: InvalidContext(); Console.ReadLine(); break; } } }