Forum / MIFARE general topics and applications / Mifare 1K to HEX
Tagged: hex
-
Dear all,
we are using Mifare RFID Cards and would like to save card IDs to a ne database.
There we need the card IDs in HEX-Format.
Right now, when scanning cards, we receive a code like this:
Mifare[8E6ACB74] 106,52084 1K (0004,08)
How can we get the HEX-Version of this Card-ID?
I thought that the part in the "[]" brackets is the HEX, but it seems to be different.
Thanks a lot!
+ 0 | - 0
Hi Mike,
How you getting this id?
If command is correct, you should get the array of bytes. If you can get String text from that byte array you can use following code:
Java
public static String toHexString(byte[] buffer) {
String bufferString = "";
for (int i = 0; i < buffer.length; i++) {
String hexChar = Integer.toHexString(buffer & 0xFF);
if (hexChar.length() == 1) {
hexChar = "0" + hexChar;
}
bufferString += hexChar.toUpperCase() + " ";
}
bufferString = bufferString.substring(0, bufferString.length()-1);
return bufferString;
}
+ 0 | - 0
*If you want to get hex data as String
+ 0 | - 0
Hi - thanks.
I am getting this from a DB of an other program. the IDs a re saved this way their - so I don'T have the access to the scanner as such.
So I need to "recode" this value to HEX
+ 0 | - 0
Hi Mike,
You can use this function to get byte array, after that, you can convert byte array to the string hex value:
public static byte[] toByteArray(int data, int length){
byte[] byteArr = ByteBuffer.allocate(INT_LENGTH).putInt(data).array();
if(length!=INT_LENGTH)
byteArr = Arrays.copyOfRange(byteArr, INT_LENGTH - length, INT_LENGTH);
return byteArr;
}
+ 0 | - 0
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.