C# 如何在OAuthBase.cs中使用SignatureType.RSASHA1

C# 如何在OAuthBase.cs中使用SignatureType.RSASHA1,c#,google-oauth,C#,Google Oauth,我搜索了很多网站,得到了相同的结果,就像下面的代码一样 public string GenerateSignature(Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, SignatureTypes signatureType, string callback, string

我搜索了很多网站,得到了相同的结果,就像下面的代码一样

public string GenerateSignature(Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, SignatureTypes signatureType, string callback, string verifier,string body_hash, out string normalizedUrl, out string normalizedRequestParameters)
    {
        normalizedUrl = null;
        normalizedRequestParameters = null;

        switch (signatureType)
        {
            case SignatureTypes.PLAINTEXT:
                return HttpUtility.UrlEncode(string.Format("{0}&{1}", consumerSecret, tokenSecret));
            case SignatureTypes.HMACSHA1:
                string signatureBase = GenerateSignatureBase(url, consumerKey, token, tokenSecret, httpMethod, timeStamp, nonce, HMACSHA1SignatureType, callback, verifier,body_hash, out normalizedUrl, out normalizedRequestParameters);

                HMACSHA1 hmacsha1 = new HMACSHA1();
                hmacsha1.Key = Encoding.ASCII.GetBytes(string.Format("{0}&{1}", UrlEncode(consumerSecret), string.IsNullOrEmpty(tokenSecret) ? "" : UrlEncode(tokenSecret)));

                return GenerateSignatureUsingHash(signatureBase, hmacsha1);
            case SignatureTypes.RSASHA1:
                throw new NotImplementedException();
            default:
                throw new ArgumentException("Unknown signature type", "signatureType");
        }
    }
有人知道如何在C#中实现“SignatureTypes.RSASHA1”吗


谢谢。

老问题,但就在我最近遇到这个问题之后,解决方案看起来有点像这样:

var rsaCryptoServiceProvider = new RSACryptoServiceProvider();
rsaCryptoServiceProvider.FromXmlString(... Your key as XML ...) 

var sha = SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(signatureBaseString));

var hashBytes = rsaCryptoServiceProvider.SignHash(sha, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);

var result = Convert.ToBase64String(hashBytes);