本文整理汇总了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
}
示例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)
}