25 lines
No EOL
522 B
C#
25 lines
No EOL
522 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace FrostFS.SDK.ModelsV2;
|
|
|
|
public class CheckSum
|
|
{
|
|
public byte[]? Hash { get; set; }
|
|
|
|
public static byte[] GetHash(byte[] content)
|
|
{
|
|
var sha256 = SHA256.Create();
|
|
return sha256.ComputeHash(content);
|
|
}
|
|
|
|
public static CheckSum CreateCheckSum(byte[] content)
|
|
{
|
|
return new CheckSum { Hash = GetHash(content) };
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Encoding.UTF8.GetString(Hash);
|
|
}
|
|
} |