Thursday 12 April 2018

ASN.1: OCTET STRING

Type: OCTET STRING
Description: This is used to represent binary data that is multiple of 8 bits. Octet string can be of any length.

It can be represented in two forms.
         Binary – '1000100'B
         Hexa - '44'H       

Example
id OCTET STRING

Example Schema
Occupation ::=  BIT STRING {
    clerk        (0),
    watchman     (1),
    engineer     (2),
    manager      (3)
}
    
Hobbies ::= BIT STRING {
    chess     (0),
    cricket   (1),
    hockey    (2),
    football  (3),
    others    (4)
}
    
Employee ::= SEQUENCE {
 name VisibleString,
 isPermanentEmployee BOOLEAN,
 id OCTET STRING,
 age INTEGER (15..60),
 occupation Occupation,
 hobbies Hobbies
}

Sample data for above schema
employee1 Employee ::= {
 name "Rama Krishna",
 isPermanentEmployee FALSE,
 id '10001000'B,
 age 30,
 occupation '010'B,
 hobbies {chess, football}
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <isPermanentEmployee><false/></isPermanentEmployee>
  <id>88</id>
  <age>30</age>
  <occupation>01</occupation>
  <hobbies>1001</hobbies>
</Employee>






Previous                                                 Next                                                 Home

No comments:

Post a Comment