A
Aerodyne
Hi all,
I've copyed this code from someone else and trying to get it to work...
public static String getKeyedDigest(String input, String key) {
:
:
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(input.getBytes());
digest = md.digest(key.getBytes());
dstr = new BigInteger(1, digest).toString(16);
/* this is important, toString leaves out initial 0 */
if (dstr.length() % 2 > 0)
dstr = "0" + dstr;
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
:
Unfortunately it retuns the correct check ... but not the leading
zero's which I need.
What it returned: 96f07821d958764gcc1fcd76d12358
expected: 0096f07821d958764gcc1fcd76d12358
or
What it returned: 0454abc257b09547a8a7f87c785328
expected: 000454abc257b09547a8a7f87c785328
TIA
I've copyed this code from someone else and trying to get it to work...
public static String getKeyedDigest(String input, String key) {
:
:
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(input.getBytes());
digest = md.digest(key.getBytes());
dstr = new BigInteger(1, digest).toString(16);
/* this is important, toString leaves out initial 0 */
if (dstr.length() % 2 > 0)
dstr = "0" + dstr;
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
:
Unfortunately it retuns the correct check ... but not the leading
zero's which I need.
What it returned: 96f07821d958764gcc1fcd76d12358
expected: 0096f07821d958764gcc1fcd76d12358
or
What it returned: 0454abc257b09547a8a7f87c785328
expected: 000454abc257b09547a8a7f87c785328
TIA