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


Golang Keys.Wipe方法代碼示例

本文整理匯總了Golang中github.com/cathalgarvey/go-minilock/taber.Keys.Wipe方法的典型用法代碼示例。如果您正苦於以下問題:Golang Keys.Wipe方法的具體用法?Golang Keys.Wipe怎麽用?Golang Keys.Wipe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cathalgarvey/go-minilock/taber.Keys的用法示例。


在下文中一共展示了Keys.Wipe方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: EncryptFileContentsWithStrings

// EncryptFileContentsWithStrings is an entry point that largely defines "normal"
// miniLock behaviour. If sendToSender is true, then the sender's ID is added to recipients.
func EncryptFileContentsWithStrings(filename string, fileContents []byte, senderEmail, senderPassphrase string, sendToSender bool, recipientIDs ...string) (miniLockContents []byte, err error) {
	var (
		senderKey, thisRecipient *taber.Keys
		recipientKeyList         []*taber.Keys
		thisID                   string
	)
	senderKey, err = taber.FromEmailAndPassphrase(senderEmail, senderPassphrase)
	if err != nil {
		return nil, err
	}
	defer senderKey.Wipe()
	if sendToSender {
		thisID, err = senderKey.EncodeID()
		if err != nil {
			return nil, err
		}
		recipientIDs = append(recipientIDs, thisID)
	}
	recipientKeyList = make([]*taber.Keys, 0, len(recipientIDs))
	// TODO: Randomise iteration here?
	for _, thisID = range recipientIDs {
		thisRecipient, err = taber.FromID(thisID)
		if err != nil {
			return nil, err
		}
		recipientKeyList = append(recipientKeyList, thisRecipient)
	}
	miniLockContents, err = EncryptFileContents(filename, fileContents, senderKey, recipientKeyList...)
	if err != nil {
		return nil, err
	}
	return miniLockContents, nil
}
開發者ID:cathalgarvey,項目名稱:go-minilock,代碼行數:35,代碼來源:encrypt.go

示例2: DecryptFileContentsWithStrings

// DecryptFileContentsWithStrings is the highest-level API for decryption.
// It uses the recipient's email and passphrase to generate their key, attempts
// decryption, and wipes keys when finished.
func DecryptFileContentsWithStrings(fileContents []byte, recipientEmail, recipientPassphrase string) (senderID, filename string, contents []byte, err error) {
	var recipientKey *taber.Keys
	recipientKey, err = taber.FromEmailAndPassphrase(recipientEmail, recipientPassphrase)
	if err != nil {
		return
	}
	defer recipientKey.Wipe()
	return DecryptFileContents(fileContents, recipientKey)
}
開發者ID:cathalgarvey,項目名稱:go-minilock,代碼行數:12,代碼來源:decrypt.go


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