views:

83

answers:

2

I am new in this Field!I have this Message and Key also i want HMAC MD5 using this two so how it is possible if possible then give some example or sample code of this.The Given link display the overall functionality i want such kind of code.Please help me.

Messgae = POSTuserMon,28Jun201010:18:33GMT7FF4471B-13C0-5A9F-BB7B-7309F1AB7F08

key = d6fc3a4a06ed55d24fecde188aaa9161

Link = http://hash.online-convert.com/md5-generator

A: 

Try this:

MessageDigest mDigest=MessageDigest.getInstance("MD5");

mDigest.update("yourstring".getBytes());

byte d[]=mDigest.digest();
StringBuffer hash=new StringBuffer();

for (int i=0; i<d.length; i++) {
    hash.append(Integer.toHexString(0xFF & d[i]));
}
Log.d("Hash",hash.toString());
Francesco
That is not an HMAC.
GregS
+1  A: 

Look at the javax.crypto.Mac class. Try Mac.getInstance("HmacMD5"); and then use the init method with your key and then use the update and doFinal methods just as you would with a MessageDigest object.

GregS
ok!i have actually implemented this but it gives me message like "No such algorithm found" so if you have implemented or have any sample code then please give me....
Ankit Vyas