Source File
userattribute.go
Belonging Package
golang.org/x/crypto/openpgp/packet
package packet
import (
)
const UserAttrImageSubpacket = 1
type UserAttribute struct {
Contents []*OpaqueSubpacket
}
func ( ...image.Image) ( *UserAttribute, error) {
= new(UserAttribute)
for , := range {
:= []byte{
0x10, 0x00, // Little-endian image header length (16 bytes)
0x01, // Image header version 1
0x01, // JPEG
0, 0, 0, 0, // 12 reserved octets, must be all zero.
0, 0, 0, 0,
0, 0, 0, 0}
if _, = .Write(); != nil {
return
}
if = jpeg.Encode(&, , nil); != nil {
return
}
.Contents = append(.Contents, &OpaqueSubpacket{
SubType: UserAttrImageSubpacket,
Contents: .Bytes()})
}
return
}
func ( ...*OpaqueSubpacket) *UserAttribute {
return &UserAttribute{Contents: }
}
, := ioutil.ReadAll()
if != nil {
return
}
.Contents, = OpaqueSubpackets()
return
}
func ( *UserAttribute) ( io.Writer) ( error) {
var bytes.Buffer
for , := range .Contents {
.Serialize(&)
}
if = serializeHeader(, packetTypeUserAttribute, .Len()); != nil {
return
}
_, = .Write(.Bytes())
return
}
func ( *UserAttribute) () ( [][]byte) {
for , := range .Contents {
if .SubType == UserAttrImageSubpacket && len(.Contents) > 16 {
= append(, .Contents[16:])
}
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |