import java.security.Security;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
public class MainClass {
public static void main(String args[]) throws Exception {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
String inputString = "www.rntsoft.com";
KeyGenerator keyGen = KeyGenerator.getInstance("HmacMD5");
SecretKey secretKey = keyGen.generateKey();
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
mac.init(secretKey);
byte[] byteData = inputString.getBytes("UTF8");
byte[] macBytes = mac.doFinal(byteData);
String macAsString = new sun.misc.BASE64Encoder().encode(macBytes);
System.out.println("Authentication code is: " + macAsString);
}
}
KeyGeneratorMac.zip( 1,198 k)