當前位置: 首頁>>代碼示例>>Golang>>正文


Golang openpgp.Entity類代碼示例

本文整理匯總了Golang中code/google/com/p/go/crypto/openpgp.Entity的典型用法代碼示例。如果您正苦於以下問題:Golang Entity類的具體用法?Golang Entity怎麽用?Golang Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Entity類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
開發者ID:Braintreep,項目名稱:scramble,代碼行數:26,代碼來源:crypto.go

示例2: PubEntToAsciiArmor

//PubEntToAsciiArmor creates ASscii Armor from pubEnt of type openpgp.Entity
func PubEntToAsciiArmor(pubEnt openpgp.Entity) (asciiEntity string, err error) {
	gotWriter := bytes.NewBuffer(nil)
	wr, errEncode := armor.Encode(gotWriter, openpgp.PublicKeyType, nil)
	if errEncode != nil {
		//		fmt.Println("Encoding Armor ", errEncode.Error())
		err = errEncode
		return
	}
	errSerial := pubEnt.Serialize(wr)
	if errSerial != nil {
		//		fmt.Println("Serializing PubKey ", errSerial.Error())
	}
	errClosing := wr.Close()
	if errClosing != nil {
		//		fmt.Println("Closing writer ", errClosing.Error())
	}
	asciiEntity = gotWriter.String()
	return
}
開發者ID:pruthvirajsinh,項目名稱:PrcIdSigner,代碼行數:20,代碼來源:signer.go

示例3: AddPublicKey

func AddPublicKey(e *openpgp.Entity) error {
	return serializeKey(e, publicKeyringFilename, func(w io.Writer) error {
		return e.Serialize(w)
	})
}
開發者ID:postfix,項目名稱:nyms-agent,代碼行數:5,代碼來源:keymgr.go

示例4: addSecretKey

func addSecretKey(e *openpgp.Entity) error {
	return serializeKey(e, secretKeyringFilename, func(w io.Writer) error {
		return e.SerializePrivate(w, nil)
	})
}
開發者ID:postfix,項目名稱:nyms-agent,代碼行數:5,代碼來源:keymgr.go

示例5: ArmorSecretKey

func ArmorSecretKey(e *openpgp.Entity) (string, error) {
	return exportArmoredKey(e, secretKeyArmorHeader, func(w io.Writer) error {
		return e.SerializePrivate(w, nil)
	})
}
開發者ID:postfix,項目名稱:nyms-agent,代碼行數:5,代碼來源:keymgr.go

示例6: ArmorPublicKey

func ArmorPublicKey(e *openpgp.Entity) (string, error) {
	return exportArmoredKey(e, publicKeyArmorHeader, func(w io.Writer) error {
		return e.Serialize(w)
	})
}
開發者ID:postfix,項目名稱:nyms-agent,代碼行數:5,代碼來源:keymgr.go


注:本文中的code/google/com/p/go/crypto/openpgp.Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。