9.2.4 Agregando usuarios y roles
using System;
using System.Security.Cryptography;
namespace CaducaRest.Core
{
public class Seguridad
{
public Seguridad()
{
}
public string GetSalt()
{
byte[] bytes = new byte[128 / 8];
using (var keyGenerator = RandomNumberGenerator.Create())
{
keyGenerator.GetBytes(bytes);
return BitConverter.ToString(bytes).ToLower();
}
}
public string GetHash(string text)
{
using (var sha256 = SHA256.Create())
{
var hashedBytes = sha256
.ComputeHash(Encoding.UTF8.GetBytes(text));
return BitConverter
.ToString(hashedBytes).ToLower();
}
}
}
}Previous9.2.3 Creando las tablas para manejar la seguridadNext9.3 Agregando seguridad a nuestros servicios
Last updated