Jenski Posted March 25, 2009 Share Posted March 25, 2009 Does anybody know what an "Octet String" is and how to convert them? I have this value "255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255" and want to convert it to a sensible format... (its the logonHours attribute from LDAP) Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted March 25, 2009 Share Posted March 25, 2009 An octet means a group of 8 (from Greek okta-). An eight-digit unsigned binary number has the range [0,111111112]=[0,25510], so assuming that each 255 in your string is in base 2 and then converted to base 10, each group is one octet, i.e. one byte. I'm not sure what a "sensible format" would constitute. Your string is just a space delimited numbers. Quote Link to comment Share on other sites More sharing options...
Jenski Posted March 26, 2009 Author Share Posted March 26, 2009 "Sensible format" = base10 value... 255 octal = 10101101 binary 10101101 = 173 decimal "255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255" "173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173" if the spaces are delimiters what do I do with the numbers? any ideas? Quote Link to comment Share on other sites More sharing options...
Jenski Posted March 26, 2009 Author Share Posted March 26, 2009 There are 21 "173"s. 21 * 173 = 3633 Does that sound feasable? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted March 26, 2009 Share Posted March 26, 2009 "Sensible format" = base10 value... How do you know they aren't already base 10? It wouldn't make sense calling it an "octet string" for other bases than 10. The words "octet" and "octal" aren't the same. "Octet" means a group of 8, while octet is the just the positional number system with the base 8. It makes sense that your 255's is in decimal. If you assume that it's the highest value then if you convert it to hex you'll have FF16, but that's only two digits. If you convert it to octal then you'll get 3778, but that's only three digits. However, if you convert it to binary then you'll get 111111112, that's eight digits, i.e. an octet of digits. if the spaces are delimiters what do I do with the numbers? any ideas? You'll probably have to lookup what that string means in the docs from where it came from. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.