Quick convert
Looking at packets on a *nix box and need to do a quick hex to decimal conversion?
Use bc, the command line UNIX calculator. Here's how...
Start bc with the command line 'bc -l'. The -l option loads in the standard math libraries needed for anything but the simplest tasks. You'll see something like this:
[jeff@paradigm ~]$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
Now change your number base with ibase. ibase allows you to change what numbering system you use for input, obase does the same for output. Since we want to convert hex, we set it to 16:
ibase = 16
Now type your hex number in and bc will convert it to decimal.
[jeff@paradigm ~]$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
ibase = 16
0028
40
I just converted the value in bytes 2 and 3 of an IP header, the total length field to decimal, showing me I have a 40 byte packet.
Use bc, the command line UNIX calculator. Here's how...
Start bc with the command line 'bc -l'. The -l option loads in the standard math libraries needed for anything but the simplest tasks. You'll see something like this:
[jeff@paradigm ~]$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
Now change your number base with ibase. ibase allows you to change what numbering system you use for input, obase does the same for output. Since we want to convert hex, we set it to 16:
ibase = 16
Now type your hex number in and bc will convert it to decimal.
[jeff@paradigm ~]$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
ibase = 16
0028
40
I just converted the value in bytes 2 and 3 of an IP header, the total length field to decimal, showing me I have a 40 byte packet.