I want to compare 2 byte arrays using the Javacard Framework.
The first array is predefined:
static byte[] PasswortA = { 'a', 'b', 'c', 'd' };
The second array will be input via command line:
case (byte) 0x03: ///send D003000004|abcd
GetPassword = new byte[buffer[ISO7816.OFFSET_LC]];
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, GetPassword, (short) 0, lc);
Util.arrayCopy(GetPassword, (short) 0, buffer, (short) 0, lc);
apdu.setOutgoingAndSend((short) 0, (short) lc);
Output:
/send D003000004|abcd
=> D0 03 00 00 04 61 62 63 64 .....abcd
(349416 nsec)
<= 61 62 63 64 90 00 abcd..
Status: No Error
I'm comparing the arrays as per: http://www.win.tue.nl/pinpasjc/docs/apis/jc222/javacard/framework/Util.html
case (byte) 0x05: ///send D005000001
if( (byte) 0 == Util.arrayCompare(PasswortA, (short) 0, GetPassword, (short) 0, lc ) ){
buffer[0] = '1';
} else {
buffer[0] = '0';
}
Output:
/send D005000001
=> D0 05 00 00 01 .....
(291102 nsec)
<= 30 90 00 0..
Status: No Error
Visually both arrays are identical, so I should be getting a 1 written in the buffer (buffer[0] = '1';) as response because when both arrays are identical the function should return a 0 as per the documentation from above.
Anyone know what I'm doing wrong, and why the arrayCompare function reports that the 2 arrays aren't identical?
Thank you!