using System.Security.Cryptography;
public class Sha512Adapter
public string Hash(string input)
var hash = SHA512.Create().ComputeHash(Encoding.UTF8.GetBytes(input));
var result = new StringBuilder(hash.Length * 2);
result.Append(b.ToString("X2"));
return result.ToString();
public static void Main()
var hashCode = RandomString(8);
var requestTimeStamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
var merchantCode = "CRIC69";
var fattyPayApiKey = "CRIC69-A11E89CF-5458-491A-B9FB-BAD2281B59BE";
var signature = ( merchantCode + "&" + requestTimeStamp + "&" + fattyPayApiKey).ToSha512Hash();
var requestUrl = "https://" + $"api.fatty168.xyz/api/v1/query/paymentMethod?Signature={signature}&MerchantCode={merchantCode}&Timestamp={requestTimeStamp}";
Console.WriteLine(requestUrl);
public static string RandomString(int length)
var random = new Random(Guid.NewGuid().GetHashCode());
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string (Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
public static class StringExtensions
public static string ToSha512Hash(this string text)
return new Sha512Adapter().Hash(text);