Guest User

r/badcode Challenge: Password Generator

a guest
Nov 27th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 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.  
  7. namespace StupidCodeForGeneratingARandomString {
  8.     class Program {
  9.         readonly static String[] badword = new string[] { "hunter2","correcthorsebatterystaple","Tr0ub4d0r&3"};
  10.         static void Main(string[] args) {
  11.             AppDomain.CurrentDomain.UnhandledException += unhandledExpection; GenerateNextPassWordCharActer(Environment.Is64BitProcess ? args : args);
  12.         }
  13.  
  14.         static void GenerateNextPassWordCharActer(string[] info) { if (int.Parse(info[0]) >= getStr_len(info[1])) {
  15.                 System.Threading.Thread.Sleep(20);
  16.                 Char charplused = (char)(new Random()).Next(48, 90);
  17.                 if (info[1] + charplused == "hunter2" | info[1] + charplused == "correcthorsebatterystaple" | badword.Contains(info[1] + charplused)) {
  18.                     throw new Exception(info[0] + ' ' + "n");
  19.                 }
  20.                 throw new Exception(info[0] + " " + info[1] + charplused);
  21.                
  22.             }
  23.             else { System.Console.WriteLine((String)info[1]); System.Threading.Thread.Sleep((int)-1d); };
  24.         }
  25.         private static void unhandledExpection(object sender, UnhandledExceptionEventArgs e) {
  26.  
  27.  
  28.              System.Diagnostics.Process.Start(System.Reflection.Assembly.GetEntryAssembly().Location, ((Exception)e.ExceptionObject).Message);}
  29.  
  30.         private static double getStr_len(String chars) {
  31.             float counter = 0;
  32.             while (counter < chars.Length) {
  33.                 counter = counter + 1;
  34.             }
  35.             return counter;
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment