K
K Viltersten
I've composed a small application that makes
use of MAC class but even though i get a mac
value, it's not correct, according to the
control values.
I wonder if i've missed anything. As far as
i've been googling, it's supposed to be
correct but it's possible that something has
slipped my eye.
String str = "1234567890ABCDEF1234567890ABCDEF";
byte[] keys = str.getBytes();
Key key = new SecretKeySpec(keys, "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(key);
byte[] results = mac.doFinal("00000000".getBytes());
StringBuilder stringBuilder = new StringBuilder();
for (byte result : results)
stringBuilder.append(
String.format("%02x", result));
String output = stringBuilder.toString();
Any ideas are welcome. Thanks in advance.
use of MAC class but even though i get a mac
value, it's not correct, according to the
control values.
I wonder if i've missed anything. As far as
i've been googling, it's supposed to be
correct but it's possible that something has
slipped my eye.
String str = "1234567890ABCDEF1234567890ABCDEF";
byte[] keys = str.getBytes();
Key key = new SecretKeySpec(keys, "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(key);
byte[] results = mac.doFinal("00000000".getBytes());
StringBuilder stringBuilder = new StringBuilder();
for (byte result : results)
stringBuilder.append(
String.format("%02x", result));
String output = stringBuilder.toString();
Any ideas are welcome. Thanks in advance.