Code example for Mac

Methods: doFinal, update

0
        byte[] sequenceBytes = new byte[4];
        sequenceBytes[0] = (byte) (sequenceNo >> 24);
        sequenceBytes[1] = (byte) (sequenceNo >> 16);
        sequenceBytes[2] = (byte) (sequenceNo >> 8);
        sequenceBytes[3] = (byte) (sequenceNo >> 0);
        mac.update(sequenceBytes);
        mac.update(data, offset, len);
 
        return mac.doFinal();
    } 
 
    /** 
     * 
     * 
     * @param keydata 
     * 
     * @throws AlgorithmInitializationException 
     */ 
    public void init(byte[] keydata) throws AlgorithmInitializationException {
        try { 
            mac = Mac.getInstance("HmacMD5");