www.pudn.com > encryption.rar > HashMAC.java
/*
Christoforos Pirillos @ Villanova University - May 1999
based on code from the book "Java Network Programming" by Hughes
*/
package encryption;
/** Message Authentication Code. It takes an existing hash algorithm and
encryption algorithm and combines them to form a MAC*/
public class HashMAC extends Hash {
protected Hash h;
protected Cipher c;
public HashMAC (Hash h, Cipher c) {
this.h = h;
this.c = c;
}
public byte[] digest (byte[] text, int off, int len) {
byte[] hash = h.digest (text, off, len);
return c.encipher (hash, 0, Math.min (hash.length,
c.blockSize()));
}
public int digestSize () {
return c.blockSize();
}
}