This command is usefull to encode ascii text into 8 bit Hex (UCS2)
for sending the payload of a PDU sms message.
If it wasn't so simple, you could put it in a script and call it ascii2hex.sh.
echo -n "202.9.98.54:8080/CGServer/serve.jsp?id=123456" |od -tx1
0000000 32 30 32 2e 39 2e 39 38 2e 35 34 3a 38 30 38 30
0000020 2f 43 47 53 65 72 76 65 72 2f 73 65 72 76 65 2e
0000040 6a 73 70 3f 69 64 3d 31 32 33 34 35 36
0000055
Just ignore the first column or cut it out and remove the non-text characters with "| cut -c 8- |tr -d ' \n' "
3230322e392e39382e35343a383038302f43475365727665722f73657276652e6a73703f69643d313233343536
HEX to ASCII
echo 31 32 33 34 35 36 |sed 's/ / p /g' |sed 's/$/ p/'|awk '{print "16i "$0}'|dc |tr ' ' '\n' |awk '{printf("%c\n",$0)}'
1
2
3
4
5
6
Here is a standard 8 bit ascii chart to verify the results.
No comments:
Post a Comment