Golang encoding/asn1.BitString type, At and RightAlign inner functions example
package encoding/asn1
BitString is the structure to use when you want an ASN.1 BIT STRING type. A bit string is padded up to the nearest byte in memory and the number of valid bits is recorded. Padding bits will be zero.
BitString's At function returns the bit at the given index. If the index is out of range it returns false.
BitString's RightAlign function returns a slice where the padding bits are at the beginning. The slice may share memory with the BitString.
Golang encoding/asn1.BitString type and inner functions usage example
package main
import (
"encoding/asn1"
"fmt"
)
func main() {
var bstr asn1.BitString
bstr.Bytes = []byte{0x82, 0x40}
bstr.BitLength = 16
fmt.Println(bstr.At(0))
fmt.Println(bstr.RightAlign)
}
Output :
1
0x22a0
Reference :
Advertisement
Something interesting
Tutorials
+11.2k CodeIgniter : How to check if a session exist in PHP?
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+15.9k Golang : Get file permission
+12.1k Golang : Sort and reverse sort a slice of runes
+10k Golang : Get escape characters \u form from unicode characters
+21.3k Golang : Create and resolve(read) symbolic links
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+43.3k Golang : Convert []byte to image
+20.8k Golang : Convert date string to variants of time.Time type examples
+12k Golang : Clean formatting/indenting or pretty print JSON result
+11.5k CodeIgniter : Import Linkedin data