var Token= BuildAuthAsync ( "GET" , body, URL) ; protected string BuildAuthAsync ( string method, string body, string uri) { var timestamp = DateTimeOffset. Now. ToUnixTimeSeconds ( ) ; string nonce = Path. GetRandomFileName ( ) ; string message = $" { method } \n { uri } \n { timestamp } \n { nonce } \n { body } \n" ; string signature = RequestSign ( message) ; times = timestamp. ToString ( ) ; noncerodom = nonce; sign = signature; return $"mchid=\" { mchid } \",nonce_str=\" { nonce } \",timestamp=\" { timestamp } \",serial_no=\" { serial_no } \",signature=\" { signature } \"" ; } protected string RequestSign ( string message) { X509Certificate2 cer = new X509Certificate2 ( "../../File/1628286360_20231122_cert/apiclient_cert.p12" , mchid, X509KeyStorageFlags. Exportable) ; if ( cer != null ) { RSA rsa = cer. GetRSAPrivateKey ( ) ; byte [ ] data = Encoding. UTF8. GetBytes ( message) ; return Convert. ToBase64String ( rsa. SignData ( data, HashAlgorithmName. SHA256, RSASignaturePadding. Pkcs1) ) ; } else { return "" ; } }