From c0c95621ea52f69bdcfbb88963dc732260512a4c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 24 Feb 2020 21:29:23 +0100 Subject: [PATCH] add hexdump() --- .../org/osmocom/IMSIPseudo/IMSIPseudo.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sim-applet/src/org/osmocom/IMSIPseudo/IMSIPseudo.java b/sim-applet/src/org/osmocom/IMSIPseudo/IMSIPseudo.java index 4847ce0..ac298a5 100755 --- a/sim-applet/src/org/osmocom/IMSIPseudo/IMSIPseudo.java +++ b/sim-applet/src/org/osmocom/IMSIPseudo/IMSIPseudo.java @@ -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];