forked from ruidfigueiredo/IdentityV3PasswordHasher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (46 loc) · 1.61 KB
/
Program.cs
File metadata and controls
52 lines (46 loc) · 1.61 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
52
using System;
using System.Linq;
using System.Security.Cryptography;
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
namespace IdentityV3PasswordHasher
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
{
PrintUsage();
return;
}
switch (args[0])
{
case "hash":
if (args.Length != 2) {
PrintUsage();
break;
}
Console.WriteLine(PasswordHasher.GenerateIdentityV3Hash(args[1]));
break;
case "verify":
if (args.Length != 3){
PrintUsage();
break;
}
var password = args[1];
var identityV3Hash = args[2];
Console.WriteLine(PasswordHasher.VerifyIdentityV3Hash(password, identityV3Hash) ? "Password is correct" : "Wrong password");
break;
default:
PrintUsage();
break;
}
}
private static void PrintUsage()
{
Console.WriteLine("Usage: " + Environment.NewLine);
Console.WriteLine("Generate ASP.NET Identity V3 Hash: hash [Password]");
Console.WriteLine("Validate ASP.NET Identity V3 Password/Hash: verify [Password] [IdentityV3Hash]");
}
}
}