Advertisement
XeCrash

BetterSeal Login via Console Application (GOLD)

Oct 16th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BetterSocks;
  7. namespace BetterSeal_Console_Login_TUT
  8. {
  9.     class Program
  10.     {
  11.         public static ConsoleKeyInfo key;
  12.         static void Main(string[] args)
  13.         {
  14.             Console.Title = "BetterSeal Login via Console Example -XeCrash";
  15.             Console.WriteLine("One moment while the application authenticates please...");
  16.             AuthResponse auth = Seal.Authenticate("AUTH TOKEN");
  17.             if (!auth.status)
  18.             {
  19.                 Environment.Exit(1234);
  20.             }
  21.             else
  22.             {
  23.                 Console.WriteLine("Application authenticated successfully!");
  24.  
  25.                 Console.WriteLine();
  26.  
  27.                 string user = "";
  28.                 Console.WriteLine("Username: ");
  29.                 do
  30.                 {
  31.                     key = Console.ReadKey(true);
  32.  
  33.                     if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
  34.                     {
  35.                         user += key.KeyChar;
  36.                         Console.Write(key.KeyChar);
  37.                     }
  38.                     else
  39.                     {
  40.                         if (key.Key == ConsoleKey.Backspace && user.Length > 0)
  41.                         {
  42.                             user = user.Substring(0, (user.Length - 1));
  43.                             Console.Write("\b \b");
  44.                         }
  45.                     }
  46.                 }
  47.                 while (key.Key != ConsoleKey.Enter);
  48.  
  49.                 Console.WriteLine(Environment.NewLine);
  50.  
  51.                 string pass = "";
  52.                 Console.WriteLine("Password: ");
  53.                 do
  54.                 {
  55.                     key = Console.ReadKey(true);
  56.  
  57.                     if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
  58.                     {
  59.                         pass += key.KeyChar;
  60.                         Console.Write("*");
  61.                     }
  62.                     else
  63.                     {
  64.                         if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
  65.                         {
  66.                             pass = pass.Substring(0, (pass.Length - 1));
  67.                             Console.Write("\b \b");
  68.                         }
  69.                     }
  70.                 }
  71.                 while (key.Key != ConsoleKey.Enter);
  72.  
  73.                 Console.WriteLine(Environment.NewLine);
  74.  
  75.                 LoginResponse lr = Seal.Login(user, pass);
  76.                 if (lr.status)
  77.                 {
  78.                     Console.WriteLine("Login Successful!");
  79.                     Console.ReadKey();
  80.                 }
  81.                 else
  82.                 {
  83.                     Console.WriteLine(lr.info);
  84.                     Console.WriteLine("Press any key to retry login...");
  85.                     Console.ReadLine();
  86.                     Console.Clear();
  87.                     Main(args);
  88.                 }
  89.             }
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement