-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (42 loc) · 1.53 KB
/
Copy pathProgram.cs
File metadata and controls
51 lines (42 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== Password Utility Console ===");
Console.WriteLine("Options: ");
Console.WriteLine("1 - Generate password hash");
Console.WriteLine("2 - Verify password against hash");
Console.WriteLine("Type 'exit' to quit.");
Console.WriteLine();
while (true)
{
Console.Write("Choose option (1/2 or 'exit'): ");
string choice = Console.ReadLine();
if (choice?.ToLower() == "exit")
break;
if (choice == "1")
{
Console.Write("Enter plain password: ");
string password = Console.ReadLine();
string passwordHash = BCrypt.Net.BCrypt.HashPassword(password);
Console.WriteLine($"Generated hash: {passwordHash}");
}
else if (choice == "2")
{
Console.Write("Enter plain password: ");
string input = Console.ReadLine();
Console.Write("Enter stored hash: ");
string hash = Console.ReadLine();
bool isMatch = BCrypt.Net.BCrypt.Verify(input, hash);
Console.WriteLine(isMatch ? "Match" : "No match");
}
else
{
Console.WriteLine("Invalid option. Please choose 1, 2, or 'exit'.");
}
Console.WriteLine();
}
Console.WriteLine("Console closed by user.");
}
}