src/Foundation/Net/Gimela.Net.Http/Authentication/DigestAuthentication.cs
/// <summary>
/// Encrypts parameters into a Digest string
/// </summary>
/// <param name="realm">Realm that the user want to log into.</param>
/// <param name="userName">User logging in</param>
/// <param name="password">Users password.</param>
/// <param name="method">HTTP method.</param>
/// <param name="uri">Uri/domain that generated the login prompt.</param>
/// <param name="qop">Quality of Protection.</param>
/// <param name="nonce">"Number used ONCE"</param>
/// <param name="nc">Hexadecimal request counter.</param>
/// <param name="cnonce">"Client Number used ONCE"</param>
/// <returns>Digest encrypted string</returns>
Encrypts parameters into a Digest string
Encrypts parameters into a Digest string
public static string Encrypt(string realm, string userName, string password, string method, string uri, string qop, string nonce, string nc, string cnonce)
    {
      string HA1 = GetHA1(realm, userName, password);
      string A2 = String.Format("{0}:{1}", method, uri);
      string HA2 = GetMD5HashBinHex2(A2);
      string unhashedDigest;
      if (qop != null)
      {
        unhashedDigest = String.Format("{0}:{1}:{2}:{3}:{4}:{5}",
                                       HA1,
                                       nonce,
                                       nc,
                                       cnonce,
                                       qop,
                                       HA2);
      }
      else
      {
        unhashedDigest = String.Format("{0}:{1}:{2}",
                                       HA1,
                                       nonce,
                                       HA2);
      }
      return GetMD5HashBinHex2(unhashedDigest);
    }
public static string Encrypt ( string realm , string userName , string password , string method , string uri , string qop , string nonce , string nc , string cnonce ) { string HA1 = GetHA1 ( realm , userName , password ) ; string A2 = String . Format ( " " , method , uri ) ; string HA2 = GetMD5HashBinHex2 ( A2 ) ; string unhashedDigest ; if ( qop != null ) { unhashedDigest = String . Format ( " " , HA1 , nonce , nc , cnonce , qop , HA2 ) ; } else { unhashedDigest = String . Format ( " " , HA1 , nonce , HA2 ) ; } return GetMD5HashBinHex2 ( unhashedDigest ) ; }
Encrypts parameters into a Digest string
Encrypts parameters into a Digest string
Digest encrypted string
Digest encrypted string
realm
string
Realm that the user want to log into.
Realm that the user want to log into .
userName
string
User logging in
User logging in
password
string
None
method
string
None
uri
string
Uri/domain that generated the login prompt.
Uri / domain that generated the login prompt .
qop
string
Quality of Protection.
Quality of Protection .
nonce
string
"Number used ONCE"
" Number used ONCE "
nc
string
Hexadecimal request counter.
Hexadecimal request counter .
cnonce
string
"Client Number used ONCE"
" Client Number used ONCE "