This commit is contained in:
2022-04-19 00:05:16 +02:00
parent e7c2ae7b8d
commit d7f2348f0d
20 changed files with 924 additions and 49 deletions

View File

@@ -1,11 +1,14 @@
using System.Security.Cryptography;
using System.Text;
using APP.DTO;
namespace APP.Utility;
public static class StringAssemble
internal static class StringAssemble
{
public static string UserInfo(User? user)
private const string RegisterSecret = "綾波レイ";
internal static string UserInfo(User? user)
{
if (user == null)
{
@@ -31,7 +34,7 @@ public static class StringAssemble
return sb.ToString();
}
public static string UserData(User? user)
internal static string UserData(User? user)
{
if (user == null)
{
@@ -56,4 +59,20 @@ public static class StringAssemble
return sb.ToString();
}
internal static string CalcSha512(string input)
{
var bytes = Encoding.UTF8.GetBytes(input);
using var hash = SHA512.Create();
var hashedInputBytes = hash.ComputeHash(bytes);
var hashedInputStringBuilder = new StringBuilder(128);
foreach (var b in hashedInputBytes)
hashedInputStringBuilder.Append(b.ToString("X2"));
return hashedInputStringBuilder.ToString().ToLower();
}
internal static string CalcSauce(long malId, string username)
{
return CalcSha512(RegisterSecret + malId + username);
}
}