add new project
This commit is contained in:
27
MySolution/ToDoApp/Utility/Utils.cs
Normal file
27
MySolution/ToDoApp/Utility/Utils.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ToDoApp.Utility
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
public static string HashPassword(string password)
|
||||
{
|
||||
using (var sha256 = SHA256.Create())
|
||||
{
|
||||
var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
|
||||
return BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool VerifyPassword(string inputPassword, string hashedPassword)
|
||||
{
|
||||
var hashedInput = HashPassword(inputPassword);
|
||||
return hashedInput.Equals(hashedPassword);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user