当前位置: 首页>>代码示例>>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;未经允许,请勿转载。