mirror of
https://github.com/bitwarden/server.git
synced 2026-01-31 14:13:18 +08:00
18 lines
472 B
C#
18 lines
472 B
C#
|
|
using System.Security.Cryptography;
|
|||
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace Bit.Test.Common.Helpers;
|
|||
|
|
|
|||
|
|
public class CryptographyHelper
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Returns a hex-encoded, SHA256 hash for the given string
|
|||
|
|
/// </summary>
|
|||
|
|
public static string HashAndEncode(string text)
|
|||
|
|
{
|
|||
|
|
var hashBytes = SHA256.HashData(Encoding.UTF8.GetBytes(text));
|
|||
|
|
var hashEncoded = Convert.ToHexString(hashBytes).ToUpperInvariant();
|
|||
|
|
return hashEncoded;
|
|||
|
|
}
|
|||
|
|
}
|