<PRE name = "code" class = "CSHARP"> using system; using system. collections. generic; using system. LINQ; using system. text; using system. security. cryptography; namespace rtsp_digest_authentication {class program {// <summary> /// MD5 32-bit encryption /// </Summary> /// <Param name = "str"> </Param >/// <returns> </returns> static string MD5 (string Str) {MD5 MD5 = new md5cryptoserviceprovider (); byte [] bytes = system. text. encoding. utf8.getbytes (STR); bytes = md5.computehash (bytes); md5.clear (); string ret = ""; for (INT I = 0; I <bytes. length; I ++) {RET + = convert. tostring (Bytes [I], 16 ). padleft (2, '0'); // Add 0} return ret. padleft (32, '0'); // fill 0} Private Static string computedigestresponse (string username, string userpwd, string realm, string cmd, string nonce, string URL) {// The "response" field is computed as: // MD5 (MD5 (<username >:< realm >:< password>): <nonce>: MD5 (<cmd >:< URL>) // or, if "fpasswordismd5" is true: // MD5 (<password >:< nonce >:md5 (<cmd>: <URL>) string HA1 = MD5 (username + ":" + realm + ":" + userpwd); string ha2 = MD5 (CMD + ":" + URL ); string response = MD5 (HA1 + ":" + nonce + ":" + ha2); return response;} static void main (string [] ARGs) {string username = "root"; string userpwd = "admin"; string realm = "operator"; string cmd = "describe"; string nonce = "3983eb84382ba9811108fc1c2e7fb8be "; string url = "rtsp: // root: [email protected]: 554/profile1 = r"; string response = computedigestresponse (username, userpwd, realm, CMD, nonce, URL ); console. writeline (response );}}}