如何将ISO 8583字符串转换为HEX值?

时间:2017-07-16 13:22:12

标签: c# hex type-conversion iso8583

我正在编写ISO8583金融交易申请表。

当我将ISO字符串发送到相应的客户端服务器时,即使对于虚拟数据,我也得到相同的响应( 15-03-00-00-02-02-0A )。

最后,客户建议我以HEX格式而不是ISO字符串格式发送ISO请求

我的ISO字符串: 服务费查询Stirng(Req)

ISOString = 01002020058020C0800E4600000005480022000500374588609902000124D15081211000047500000F30303035303632372020202020203933363139343030303738340061525331544F5055502D37313030373130302D53434F444530303030303030303132303030303030303120202020202020202020202020202020202020200043554930303035303632373030303030303933363139343030303030303030353438313930383135313630380080004849503137322E32322E38302E39382020202C30303A34303A45463A46333A30423A36322C3730313438303034323336390010494475736572202020200009424E5430303030303200054156303352

我已将上述字符串转换为HEX by,

  byte[] Hexdata = Enumerable.Range(0, hex.Length)
                             .Where(x => x % 2 == 0)
                             .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
                             .ToArray();

当我在控制台中打印时, (看起来相同的字符串我回来了)

01002020058020C0800E4600000005480022000500374588609902000124D15081211000047500000F30303035303632372020202020203933363139343030303738340061525331544F5055502D37313030373130302D53434F444530303030303030303132303030303030303120202020202020202020202020202020202020200043554930303035303632373030303030303933363139343030303030303030353438313930383135313630380080004849503137322E32322E38302E39382020202C30303A34303A45463A46333A30423A36322C3730313438303034323336390010494475736572202020200009424E5430303030303200054156303352

OR

当我通过Notepad ++(Hexeditor)进行转换时,我得到这样的

30 31 30 30 32 30 32 30 30 35 38 30 32 30 43 30 38 30 30 45 34 36 30 30 30 30 30 30 30 35 34 38 30 30 32 32 30 30 30 35 30 30 33 37 34 35 38 38 36 30 39 39 30 32 30 30 30 31 32 34 44 31 35 30 38 31 32 31 31 30 30 30 30 34 37 35 30 30 30 30 30 46 33 30 33 30 33 30 33 35 33 30 33 36 33 32 33 37 32 30 32 30 32 30 32 30 32 30 32 30 33 39 33 33 33 36 33 31 33 39 33 34 33 30 33 30 33 30 33 37 33 38 33 34 30 30 36 31 35 32 35 33 33 31 35 34 34 46 35 30 35 35 35 30 32 44 33 37 33 31 33 33 30 33 37 33 31 33 30 33 30 32 44 35 33 34 33 34 46 34 34 34 35 33 30 33 30 33 30 33 30 33 30 33 30 33 30 33 30 33 31 33 32 33 30 33 30 33 30 33 30 33 30 33 30 33 30 33 31 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 32 30 30 30 34 33 35 35 34 39 33 30 33 30 33 30 33 35 33 30 33 36 33 32 33 37 33 30 33 30 33 30 33 30 33 30 33 30 33 39 33 33 33 36 33 31 33 39 33 34 33 30 33 30 33 30 33 30 33 30 33 30 33 30 33 30 33 35 33 34 33 38 33 31 3 3 39 33 30 33 38 33 31 33 35 33 31 33 36 33 30 33 38 30 30 38 30 30 30 34 38 34 39 35 30 33 31 33 37 33 32 32 45 33 32 33 32 32 45 33 38 33 30 32 45 33 39 33 38 32 30 32 30 32 30 32 43 33 30 33 30 33 41 33 34 33 30 33 41 34 35 34 36 33 41 34 36 33 33 33 41 33 30 34 32 33 41 33 36 33 32 32 43 33 37 33 30 33 31 33 34 33 38 33 30 33 30 33 34 33 32 33 33 33 36 33 39 30 30 31 30 34 39 34 34 37 35 37 33 36 35 37 32 32 30 32 30 32 30 32 30 30 30 30 39 34 32 34 45 35 34 33 30 33 30 33 30 33 30 33 30 33 32 30 30 30 35 34 31 35 36 33 30 33 33 35 32

这种转换是否正确?

请告诉我。

谢谢。

0 个答案:

没有答案