github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/model/v1beta1/public_key.go (about) 1 package v1beta1 2 3 import ( 4 "encoding/base64" 5 ) 6 7 type PublicKey []byte 8 9 func (pk PublicKey) MarshalText() ([]byte, error) { 10 return []byte(base64.StdEncoding.EncodeToString(pk)), nil 11 } 12 13 func (pk *PublicKey) UnmarshalText(text []byte) error { 14 ba, err := base64.StdEncoding.DecodeString(string(text)) 15 if err != nil { 16 return err 17 } 18 *pk = ba 19 return nil 20 }