Golang encoding/asn1.Unmarshal function example
package encoding/asn1
Unmarshal parses the DER-encoded ASN.1 data structure b(1st param) and uses the reflect package to fill in an arbitrary value pointed at by val(2nd value). Because Unmarshal uses the reflect package, the structs being written to must use upper case field names.
see the rest of the description at http://golang.org/pkg/encoding/asn1/#Unmarshal
Golang encoding/asn1.Unmarshal function usage example
var raw []byte // pem block
block, _ := pem.Decode(raw)
raw := block.Bytes
key := struct {
Version int // remember... must use upper case field names
P *big.Int
Q *big.Int
G *big.Int
Priv *big.Int
Pub *big.Int
}{}
var rest []byte
rest, err = asn1.Unmarshal(raw, &key)
Reference :
Advertisement
Something interesting
Tutorials
+6.9k Nginx : Password protect a directory/folder
+7k Golang : Takes a plural word and makes it singular
+7.7k Gogland : Where to put source code files in package directory for rookie
+29.2k Golang : missing Git command
+14.4k Golang : How to filter a map's elements for faster lookup
+14.4k Golang : Find network of an IP address
+5.9k AWS S3 : Prevent Hotlinking policy
+25.3k Golang : Convert uint value to string type
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+17.4k Golang : Multi threading or run two processes or more example
+4.7k Unix/Linux : How to pipe/save output of a command to file?