Code example for MessageDigest

Methods: digest, reset, update

0
        String uri = request.substring(pos+1, enduri);
        String nc = String.format("%08x", _nounce_count);
        String cnonce = String.format("%08x", _randGen.nextInt());
 
        String plaintext = method+":"+uri;
        mdigest.reset();
        mdigest.update(plaintext.getBytes());
        byte[] digest = this.mdigest.digest();
        BigInteger bigInt = new BigInteger(1,digest);
        String ha2 = bigInt.toString(16);
        plaintext =_ha1+":"+_nounce+":"+nc+":"+cnonce+":auth:"+ha2;
        this.mdigest.reset();
        this.mdigest.update(plaintext.getBytes());
        digest = this.mdigest.digest();
        bigInt = new BigInteger(1,digest);
        String reponse = bigInt.toString(16);
 
 
         String res = String.format(
                 "Authorization: Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", qop=auth, nc=%s, cnonce=\"%s\", response=\"%s\", opaque=\"%s\"\r\n", 
                 _http_user,_http_realm,_nounce,uri,nc,cnonce,reponse,_opaque);