Use hex numbers

This commit is contained in:
Bob Mottram 2017-01-13 20:58:54 +00:00
parent 1ada2d7a78
commit 61ef4a3c35
1 changed files with 4 additions and 3 deletions

View File

@ -346,10 +346,11 @@ function domain_to_hex_string {
segment=$(echo "$domain" | awk -F '.' "{print \$$ctr}")
while [ ${#segment} -gt 0 ]
do
if [ ${#segment} -lt 10 ]; then
echo -n "|0${#segment}|$segment"
hexnum=$(echo "obase=16; $segment" | bc)
if [ ${hexnum} -lt 2 ]; then
echo -n "|0${hexnum}|$segment"
else
echo -n "|${#segment}|$segment"
echo -n "|$hexnum|$segment"
fi
ctr=$((ctr + 1))
segment=$(echo "$domain" | awk -F '.' "{print \$$ctr}")