我使用smartcardio库通过Java与智能卡进行通信。我从卡片上得到回复,然后我想将回复解码为文本,这有点复杂。
示例:
响应如下:
ResponseAPDU: 145 bytes, SW=9000
Hex : 13E013A801C800001AB4138E03931BC6142B1C3214371C5114531C5B04FA24FB0026001252AE42800554003E200005621D670012002252AF9400055502C518001083188700B2195501C91BEB04601C6904FC1D660022003652B0E580055601AF180010561875108F189200941B9213CA1BD613D81BDB143E1C4314481C4A144F04511CA315261D2D656B0036001A529000
Binary: 10011111000000001001110101000000000011100100000000000000000000001101010110100000100111000111000000011100100110001101111000110000101000010101100011100001100100001010000110111000111000101000100010100010100110001110001011011000001001111101000100100111110110000000000100110000000000001001001010010101011100100001010000000000001010101010000000000001111100010000000000000000001010110001000011101011001110000000000010010000000000010001001010010101011111001010000000000000001010101010100000010110001010001100000000000000100001000001100011000100001110000000010110010000110010101010100000001110010010001101111101011000001000110000000011100011010010000010011111100000111010110011000000000001000100000000000110110010100101011000011100101100000000000010101010110000000011010111100011000000000000001000001010110000110000111010100010000100011110001100010010010000000001001010000011011100100100001001111001010000110111101011000010011110110000001101111011011000101000011111000011100010000110001010001001000000111000100101000010100010011110000010001010001000111001010001100010101001001100001110100101101011001010110101100000000001101100000000000011010010100101001000000000000
After execute :
System.out.println("Response : " + new String(r.getData()));
new String(r.getBytes(), 0, r.getBytes().length, "UTF8")); --> give me almost the same result.
I get :
��� ����+27QS[�$� & R�B�T > bg "R�� U� �� �U��`i�f " 6R���V� Vu�� ������>CHJOQ�&-ek 6 R�
是否有其他方法可以解码卡片到文字的回复?收到卡片的回复真是太好了,但是即使我什至不知道得到什么也没用。 我找到的关于解码apdu响应的大多数解决方案都像上面的方法一样简单,但是这种解决方案还不够。
还尝试通过检查所有字符集来解码响应:
SortedMap<String,Charset> charsets = Charset.availableCharsets();
Iterator i = charsets.entrySet().iterator();
while (i.hasNext())
{
Map.Entry m = (Map.Entry)i.next();
String key = (String)m.getKey();
System.out.println("Response charset " + key + " : " + new String(r.getBytes(), 0, r.getBytes().length, key));
}
答案 0 :(得分:0)
Read Binary
可以轻松地(即,通常不返回)返回非文本数据。这取决于应用程序的规范。如果没有其他信息,则该卡符合什么规格以及它的文件名称,我们的猜测并不比您的猜测更好。注意,智能卡通常会使用称为BER-TLV的结构化数据格式。首先,请尝试掌握ISO 7816第4部分的介绍。