Iso 8583 protocol, bytes, encoding random notes

kiran
2 min readMar 12, 2021

--

Some random notes for my self

let data = {    0 : "1200",    3 : "310000",    102 : "123456789123456",}

Ultimately data is a stream of bytes and further down bits.

So how that data is converted to bits is to do with how to interpret the type of data.

  • >

Assume we have a 1a string with hex bytes in it.So it is 26 in decimal and hence 00011010 in binary.Funny things is you could convert 1 to 0001 and a to 1010.

But if 1a is in ascii, 00110001 01100001 is the binary form.

  • >

Now lets take the string 1200.We want to send this in utf-8 format while sending.

So we find the hex code for each character from this table and get 31 32 30 30 in utf-8 for 1200.

To get binary stream for this I am not sure if it is straight forward.But we can assume for the sake of this discussion and convert hex 31 to 00110001 in binary.Similarly the rest.

00110011 00110001 00100000 00110011 00110010 00100000 00110011 00110000 00100000 00110011 00110000

  • >

We take the binary stream and then try to decode up from there and for which too we need to know what is the format of the bytes such as the first ten bytes are hex and next bytes are utf-8 etc.So now we can decode accordingly.

  • >

Now in node buffers represent a stream of bytes.

So when we print a buffer, what gets printed ? A stream of bits could represent anything.Like 00110000 in utf-8 is 0.The same in hex is 30.

As per Buffer docs, the default is utf-8.Which means the bits are decoded as utf-8 data.

Note: oxac is 172 in decimal and 10101100 in binary or could convert a to 1010 and c to 1100 and get the binary version of oxac.

Out:

mti: 1200
bitmap hex: a0000000000000000000000004000000
bitmap binary: 10100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000
raw: <Buffer 31 32 30 30 a0 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 33 31 30 30 30 30 31 34 31 38 37 30 30 31 31 30 30 30 31 30 30 34>
raw string: 1200�3100001418700110001004
raw binary: 1200 3100001418700110001004
bufer msg: <Buffer 00 2a 31 32 30 30 a0 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 33 31 30 30 30 30 31 34 31 38 37 30 30 31 31 30 30 30 31 30 30 34>

also check this https://www.quora.com/What-is-the-difference-between-binary-and-BCD-code

--

--

kiran

I am a software engineer by profession. I write so as to remind my selves when I forget :-)