Hash text using SHA512


    /// hash using SHA512
    public static string Hash_SHA512(Dictionary<string, string> keyValues, string secret)
    {
        keyValues.Remove("sign");
        StringBuilder builder = new();
        foreach (var item in keyValues.Select(t => t).OrderBy(t => t.Key))
        {
                builder.Append($"{item.Key}={item.Value}&");
        }
        using SHA512 sha521Hash = SHA512.Create();
        //From String to byte array
        byte[] sourceBytes = Encoding.UTF8.GetBytes(builder.ToString().TrimEnd('&') + secret);
        byte[] hashBytes = sha521Hash.ComputeHash(sourceBytes);
        string hash = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
        return hash.ToLower();
    }

Summary:

Hash string using SHA512 for signature verification