Jump to content

Octet String


Jenski

Recommended Posts

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)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

"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?

Link to comment
Share on other sites

"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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.