mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: paste views; configuration validation; hmacsha256 method; enhance paste clean up serivce; paste view clean up service;
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace SharpbinV3.Server
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SharpbinV3.Server
|
||||
{
|
||||
public class Utilities
|
||||
{
|
||||
@@ -8,5 +10,16 @@
|
||||
var random = new Random();
|
||||
return new string([.. Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)])]);
|
||||
}
|
||||
|
||||
public static string ComputeHmacSha256(string secret, string input)
|
||||
{
|
||||
var secretBytes = System.Text.Encoding.UTF8.GetBytes(secret);
|
||||
var inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
|
||||
|
||||
using var hmac = new HMACSHA256(secretBytes);
|
||||
var hashBytes = hmac.ComputeHash(inputBytes);
|
||||
|
||||
return Convert.ToHexString(hashBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user