Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BetterSocks;
- namespace BetterSeal_Console_Login_TUT
- {
- class Program
- {
- public static ConsoleKeyInfo key;
- static void Main(string[] args)
- {
- Console.Title = "BetterSeal Login via Console Example -XeCrash";
- Console.WriteLine("One moment while the application authenticates please...");
- AuthResponse auth = Seal.Authenticate("AUTH TOKEN");
- if (!auth.status)
- {
- Environment.Exit(1234);
- }
- else
- {
- Console.WriteLine("Application authenticated successfully!");
- Console.WriteLine();
- string user = "";
- Console.WriteLine("Username: ");
- do
- {
- key = Console.ReadKey(true);
- if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
- {
- user += key.KeyChar;
- Console.Write(key.KeyChar);
- }
- else
- {
- if (key.Key == ConsoleKey.Backspace && user.Length > 0)
- {
- user = user.Substring(0, (user.Length - 1));
- Console.Write("\b \b");
- }
- }
- }
- while (key.Key != ConsoleKey.Enter);
- Console.WriteLine(Environment.NewLine);
- string pass = "";
- Console.WriteLine("Password: ");
- do
- {
- key = Console.ReadKey(true);
- if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
- {
- pass += key.KeyChar;
- Console.Write("*");
- }
- else
- {
- if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
- {
- pass = pass.Substring(0, (pass.Length - 1));
- Console.Write("\b \b");
- }
- }
- }
- while (key.Key != ConsoleKey.Enter);
- Console.WriteLine(Environment.NewLine);
- LoginResponse lr = Seal.Login(user, pass);
- if (lr.status)
- {
- Console.WriteLine("Login Successful!");
- Console.ReadKey();
- }
- else
- {
- Console.WriteLine(lr.info);
- Console.WriteLine("Press any key to retry login...");
- Console.ReadLine();
- Console.Clear();
- Main(args);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement