dragonbs

02. Encrypting Password

Apr 2nd, 2023
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System.Text.RegularExpressions;
  2.  
  3. int o = int.Parse(Console.ReadLine());
  4. string patternFromOgi = @"^(.+)(>)(?<number>[0-9]{3})(\|)(?<lower>[a-z]{3})(\3)(?<upper>[A-Z]{3})(\3)(?<symbols>.{3})(<)(\1)$";
  5. for (int i = 0; i < o; i++)
  6. {
  7.  
  8.     string inputFromOgi = Console.ReadLine();
  9.     Regex regex = new Regex(patternFromOgi);
  10.     Match match = regex.Match(inputFromOgi);
  11.     if (match.Success)
  12.     {
  13.         string numbersFromOgi = match.Groups["number"].ToString();
  14.         string lowerFromOgi = match.Groups["lower"].ToString();
  15.         string upperFromOgi = match.Groups["upper"].ToString();
  16.         string symbolsFromOgi = match.Groups["symbols"].ToString();
  17.         string finalPasswordFromOgi = numbersFromOgi + lowerFromOgi + upperFromOgi + symbolsFromOgi;
  18.         Console.WriteLine($"Password: {finalPasswordFromOgi}");
  19.     }
  20.     else
  21.     {
  22.         Console.WriteLine("Try another password!");
  23.     }
  24. }
Add Comment
Please, Sign In to add comment