你能解释一下我的两个哈希之间的微小差别吗?

时间:2014-10-21 06:06:02

标签: c# .net wcf rest oauth

我正在尝试实施WCF OAuth restful Web API服务。 如果不知道代码,你可以解释我的两个哈希之间的微小差别:

  dictionary["oauth_signature"]   "URirekG5i5MbWxoinc4bi4H8j1g%3D"    string
  hash                            "URirekG5i5MbWxoinc4bi4H8j1g="      string

我使用RESTClient(firefox插件)来测试我的WCF OAuth restful Web API服务。 I followed this article

似乎有些东西被添加到字典[“oauth_signature”]的末尾,或者我生成的哈希中缺少某些东西。但是什么?

            if (dictionary["oauth_consumer_key"] != null)
            {
                // to get uri without oauth parameters
                string uri = context.UriTemplateMatch.RequestUri.ToString();
                string consumersecret = "suryabhai";
                OAuthBase oauth = new OAuthBase();
                string hash = oauth.GenerateSignature(
                    new Uri(uri),
                    dictionary["oauth_consumer_key"],
                    consumersecret,
                    null, // totken
                    null, //token secret
                    "GET",
                    dictionary["oauth_timestamp"],
                    dictionary["oauth_nonce"],
                    out normalizedUrl,
                    out normalizedRequestParameters
                    );
                Authenticated = dictionary["oauth_signature"] == hash;
            }
            return Authenticated;

1 个答案:

答案 0 :(得分:3)

在您的应用程序的某处,您的哈希值已经过URL编码。这意味着,=符号(URL中的特殊字符)已编码为%3D。如果你解码它们,它们将匹配。