Code example for SecretKeySpec

Methods: getAlgorithm

0
	 * @return 
	 * @throws Exception 
	 */ 
	public static String encryptHMAC(String source, String key) throws Exception {
		byte[] data = source.getBytes();
		SecretKey secretKey = new SecretKeySpec(Base64Util.decryptBASE64(key)
				.getBytes(), KEY_MAC);
		Mac mac = Mac.getInstance(secretKey.getAlgorithm());
		mac.init(secretKey);
 
		byte[] return_data = mac.doFinal(data);
		return new String(return_data);
	} 
 
}