add hexdump()

This commit is contained in:
Neels Hofmeyr 2020-02-24 21:29:23 +01:00
parent 984627047e
commit c0c95621ea
1 changed files with 19 additions and 0 deletions

View File

@ -263,6 +263,25 @@ public class IMSIPseudo extends Applet implements ToolkitInterface, ToolkitConst
return mi;
}
private byte nibble2hex(byte nibble)
{
nibble = (byte)(nibble & 0xf);
if (nibble < 0xa)
return (byte)('0' + nibble);
else
return (byte)('a' + nibble - 0xa);
}
private byte[] hexdump(byte data[])
{
byte res[] = new byte[(byte)(data.length*2)];
for (byte i = 0; i < data.length; i++) {
res[(byte)(i*2)] = nibble2hex((byte)(data[i] >> 4));
res[(byte)(i*2 + 1)] = nibble2hex(data[i]);
}
return res;
}
private void showIMSI() {
/* 3GPP TS 31.102 4.2.2: IMSI */
byte[] IMSI = new byte[9];