aboutsummaryrefslogtreecommitdiff
path: root/ber/class_test.go
blob: 5803e28bdc82399dcbe74bc21e30cbbc9136c920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ber

import "fmt"

func ExampleIdent() {
	b := []byte{
		0x02, 0x04, 0x0A, 0x30,
		0x40, 0x61, 0x7E,
		0x80, 0xA1, 0xBE,
	}
	for _, v := range b {
		c, k, t := Ident(v)
		if c == Universal {
			fmt.Printf("0x%.2X: %v %v %v\n",
				v, c, k, t)
		} else {
			fmt.Printf("0x%.2X: %v %v 0x%.2X\n",
				v, c, k, byte(t))
		}
	}
	// Output:
	// 0x02: Universal Primitive Integer
	// 0x04: Universal Primitive Octet String
	// 0x0A: Universal Primitive Enumerated
	// 0x30: Universal Constructed Sequence / Of
	// 0x40: Application Primitive 0x00
	// 0x61: Application Constructed 0x01
	// 0x7E: Application Constructed 0x1E
	// 0x80: Context-specific Primitive 0x00
	// 0xA1: Context-specific Constructed 0x01
	// 0xBE: Context-specific Constructed 0x1E
}