本文整理匯總了Golang中code/google/com/p/go/crypto/openpgp.Entity.SerializePrivate方法的典型用法代碼示例。如果您正苦於以下問題:Golang Entity.SerializePrivate方法的具體用法?Golang Entity.SerializePrivate怎麽用?Golang Entity.SerializePrivate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/google/com/p/go/crypto/openpgp.Entity
的用法示例。
在下文中一共展示了Entity.SerializePrivate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SerializeKeys
func SerializeKeys(entity *openpgp.Entity) (privKeyArmor, pubKeyArmor string, err error) {
// First serialize the private parts.
// NOTE: need to call this in order to initialize the newly created entities,
// otherwise entity.Serialize() will fail
// https://code.google.com/p/go/issues/detail?id=6483
b := bytes.NewBuffer(nil)
w, _ := armor.Encode(b, openpgp.PrivateKeyType, nil)
err = entity.SerializePrivate(w, nil)
if err != nil {
return "", "", err
}
w.Close()
privKeyArmor = b.String()
// Serialize the public key.
b.Reset()
w, _ = armor.Encode(b, openpgp.PublicKeyType, nil)
err = entity.Serialize(w)
if err != nil {
return "", "", err
}
w.Close()
pubKeyArmor = b.String()
return
}
示例2: addSecretKey
func addSecretKey(e *openpgp.Entity) error {
return serializeKey(e, secretKeyringFilename, func(w io.Writer) error {
return e.SerializePrivate(w, nil)
})
}
示例3: ArmorSecretKey
func ArmorSecretKey(e *openpgp.Entity) (string, error) {
return exportArmoredKey(e, secretKeyArmorHeader, func(w io.Writer) error {
return e.SerializePrivate(w, nil)
})
}