tglogo.png
0 LIKES

Snippet


Convert Hex IP to Dec by gennarino

In Category General IRC Posted by Snippets On 12/04/23

Routine to convert an Hex IP in a Decimal IP
/* 
Routine to convert an Hex IP in a Decimal IP

Use:     %res = $Hex2IP( hex_IP )

Alias h2d is used for test purpose only.
Try::     /h2d 598af63b
Output:     89.138.246.59
*/

alias h2d   {
  var %a = $Hex2IP( $1 )
  .echo 4 -a %a
}

alias -l Hex2IP {
  var %id = $1

  var %d1 = $mid(%id, 0, 2)
  var %d2 = $mid(%id, 3, 2)
  var %d3 = $mid(%id, 5, 2)
  var %d4 = $mid(%id, 7, 2)

  return  $base( %d1,16,10 ) $+ . $+ $base( %d2,16,10 ) $+ . $+ $base( %d3,16,10 ) $+ . $+ $base( %d4,16,10 )
}


Comments 0


Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand