Dear community, I'm just coding a little diameter avp converion and I need to pad the AVP string. According to RFC 3588, AVP string
that do not align on a 32-bit boundary MUST have the necessary padding 00.
examples (space between values is only to shown better and should be removed on final string):
e4 99 68 f8 41 ==> e4 99 68 f8 41 00 00 00
40 ==> 40 00 00 00
2a 2e ==> 2a 2e 00 00
My simple code just takes a string and convert it in hex, but I need to add 00 padding on the right basing on above rules/example:
$Origin_Host_CER="example.me";
$Origin_Host_CER =~ s/(.)/sprintf '%02x', ord $1/seg;
print "STX2HEX: $Origin_Host_CER\n\n";
print length($Origin_Host_CER)/2;
This will result in:
STX2HEX: 6578616d706c652e6d65
10
So, final string should have 2 padding:
6578616d706c652e6d650000
Could someone help me to understand how to do that possibility without use any external module?
Thank you
Lucas