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
+13.4k Golang : Read from buffered reader until specific number of bytes
+13.8k Generate salted password with OpenSSL example
+14.8k Golang : Get URI segments by number and assign as variable example
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+10.2k Golang : How to get quoted string into another string?
+22.1k Golang : Join arrays or slices example
+7.5k Golang : How to stop user from directly running an executable file?
+17.4k Golang : Get future or past hours, minutes or seconds
+12.7k Android Studio : Highlight ImageButton when pressed on example
+7.4k Golang : Convert source code to assembly language
+17.6k Golang : Upload/Receive file progress indicator
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?