秘钥长度可以随便输吗
public static final String PASSWORD="imooc security hmac";
public static void bcHmacMD5(){
HMac hmac=new HMac(new MD5Digest());
hmac.init(new KeyParameter(Hex.decode("aaaaaaaaa")));
hmac.update(PASSWORD.getBytes(), 0, PASSWORD.getBytes().length);
byte [] bcHmacMD5bytes=new byte [hmac.getMacSize()];
hmac.doFinal(bcHmacMD5bytes, 0);
System.out.println("bc HmacMD5="+org.apache.commons.codec.binary.Hex.encodeHexString(bcHmacMD5bytes));
}
java.security.NoSuchAlgorithmException: aaaaaaaaaa KeyGenerator not available
为什么秘钥是十个a,我少输就会报异常