コード例 #1
0
        internal static string CreateRequestDigest(NameValueCollection parameters)
        {
            string username = parameters["username"];
            string password = parameters["password"];
            string realm    = parameters["realm"];
            string text     = parameters["nonce"];
            string uri      = parameters["uri"];
            string text2    = parameters["algorithm"];
            string text3    = parameters["qop"];
            string text4    = parameters["nc"];
            string text5    = parameters["cnonce"];
            string method   = parameters["method"];
            string value    = (text2 == null || !(text2.ToLower() == "md5-sess")) ? HttpUtility.A1(username, password, realm) : HttpUtility.A1(username, password, realm, text, text5);
            string value2   = (text3 == null || !(text3.ToLower() == "auth-int")) ? HttpUtility.A2(method, uri) : HttpUtility.A2(method, uri, parameters["entity"]);
            string secret   = HttpUtility.Hash(value);
            string data     = (text3 == null) ? string.Format("{0}:{1}", text, HttpUtility.Hash(value2)) : string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
            {
                text,
                text4,
                text5,
                text3,
                HttpUtility.Hash(value2)
            });

            return(HttpUtility.KD(secret, data));
        }