Mac reset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Mac reset method.

This code example shows how to use the following methods:doFinal, reset, update
                                                                    SecurityException { 
        Mac mac = currentMAC == null ? defaultMAC : currentMAC;
        if (mac == null) {
            throw new SecurityException("no key for mac calculation");
        } 
        mac.reset();
        mac.update(data, start, end - start + 1);
        mac.doFinal(data, end + 1);
    } 
 
    /** 
     * validate a mac that is at the end of a piece of byte array data 
     *  
     * @param data 
     *            to validate 
     * @param start 
     *            of the data - inclusive 
     * @param end 
     *            of the data - inlcusive, mac present after this 
     * @throws SecurityException 
6
CodeRank
This code example shows how to use the following methods:clone, doFinal, getMacLength, init, reset
        Security.removeProvider(mProv.getName());
    } 
     
    protected void checkResult(Mac mac) throws InvalidKeyException,
            InvalidAlgorithmParameterException { 
        assertEquals("Incorrect MacLength", mac.getMacLength(), 0);
        byte [] b = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0};
        SecretKeySpec scs = new SecretKeySpec(b, "SHA1");
        AlgParSpec parms = new AlgParSpec();
        tmpKey tKey = new tmpKey();
        mac.init(scs);        
        byte[] bb = mac.doFinal();
        assertEquals(bb.length, 0);
        mac.reset();
        bb = mac.doFinal();
        assertEquals(bb.length, 1);
        try { 
            mac.init(null);
            fail("InvalidKeyException should be thrown");
        } catch (InvalidKeyException e) {

5
CodeRank
This code example shows how to use the following methods:doFinal, reset
        } 
 
    } 
 
    public synchronized byte[] digest(byte[] message) {
        mac.reset();
        return mac.doFinal(message);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:doFinal, reset, update
   * Hash bytes with given hasher 
   * Input: message to hash, HMAC hasher 
   * Output: hashed byte[]. 
   */ 
  public static byte[] digestBytes(byte[] message, Mac hasher) {
    hasher.update(message);
    byte[] ret = hasher.doFinal();
    hasher.reset();
    return ret;
  } 
} 
5
CodeRank
This code example shows how to use the following methods:doFinal, reset
	 * Calculates the digest of a particular message. 
	 * @param message 
	 * @return 
	 */ 
	public synchronized byte [] calculateDigest(String message){
		mac.reset();
		byte[] digest = mac.doFinal(message.getBytes());
		return(digest);
	} 
	 
	 
} 
5
CodeRank
This code example shows how to use the following methods:reset
		} 
	} 
 
	@Override 
	public void reset() throws CryptoException { 
		hmac.reset();
	} 
 
	@Override 
	public void update(byte[] data) throws CryptoException {
		if (data == null)
			return; 
		hmac.update(data, 0, data.length);
	} 
 
	@Override 
	public void update(byte[] data, int offset, int length) {
		hmac.update(data, offset, length);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:reset
		} 
	} 
	 
	@Override 
	public void reset() { 
		mac.reset();
	} 
	 
	@Override 
	public String getAlgorithm() {
		return this.algorithm;
	} 
	 
	@Override 
	public int getHashLength() { 
		return this.mac.getMacLength();
	} 
 
} 
4
CodeRank
reset Method Overview
Resets this Mac instance to its initial state.
See Code Examples for other Java 8 Mac Methods: