Hex Encode String


#1

Is it possible to hex encode a variable directly in the asterisk dial plan so that I can offer it in a SIP header?

If not would I be able to call an external script to do this by passing the variable I want encoded to the script, and have it return the encoded variable so that I can stick it in a header?

Any examples anyone could provide would be fantastic!

Thank you.


#2

Yes.


#3

Hi thank you. Are there any related links or how to knowledge base articles you might be able to share to help me with this?


#4

If any one else runs in to this here is an example of how I solved this:

exten => _+1NPANXXXXXX,1,GotoIf($["${SIP_HEADER(Diversion)}" = “”]?noagi)
exten => _+1NPANXXXXXX,n,AGI(div2hex.php,${SIP_HEADER(Diversion)})
exten => _+1NPANXXXXXX,n,SIPAddHeader(X-Header: ${divhex})
exten => _+1NPANXXXXXX,n(noagi),Dial(SIP/${EXTEN}@test)
exten => _+1NPANXXXXXX,n,Hangup

I had to write a php script to break up the header, encode the string and pass it back to the dialplan


#5

I was expecting you to do “core show functions” and find:

CentOS53*CLI> core show function URIENCODE
-= Info about function ‘URIENCODE’ =-

[Syntax]
URIENCODE()

[Synopsis]
Encodes a string to URI-safe encoding according to RFC 2396.

[Description]
Not available