Hello,
I'm semi successfull at finally creating this algorithm and running it againts the variables I need to. But it doesn't seem to be a true HMAC-MD5 hash...
The successfull hash I create with an ASP script that works and plugs into my gateway looks like this...
f81633aec015f23fbfd57bec77529c31
The one I create with the following code looks like this and has a trailing == in every one and doesn't work and I dont want to use ASP for this I would like to use java?
JN4Kuk4KFN6pO/XA/wdAWg==
Can anyone lend a hand pleeeeeeeeese...
public static String HMAC(String values, String myKeyString){
String output = "";
try {
PBEKeySpec keySpec = new PBEKeySpec(myKeyString.toCharArray());
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey key = skf.generateSecret(keySpec);
//I use "hmacMD5" here becuase when I use
//key.getAlgorithm() it returns nothing
Mac mac = Mac.getInstance("hmacMD5");
mac.init(key);
// Encode the string into bytes using utf-8 and digest it
byte[] utf8 = values.getBytes("utf8");
byte[] digest = mac.doFinal(utf8);
// convert the digest into a string
String digestB64 = new sun.misc.BASE64Encoder().encode(digest);
output += digestB64;
} catch (InvalidKeyException e) {
} catch (NoSuchAlgorithmException e) {
} catch (UnsupportedEncodingException e) {
} catch (InvalidKeySpecException e) {
}
return output;
}
thanks