You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
773 B

2 years ago
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);
}
}
}