本文整理汇总了Golang中github.com/keybase/client/go/libkb.GenericKey.DecryptFromString方法的典型用法代码示例。如果您正苦于以下问题:Golang GenericKey.DecryptFromString方法的具体用法?Golang GenericKey.DecryptFromString怎么用?Golang GenericKey.DecryptFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/libkb.GenericKey
的用法示例。
在下文中一共展示了GenericKey.DecryptFromString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fetchLKS
// fetchLKS gets the encrypted LKS client half from the server.
// It uses encKey to decrypt it. It also returns the passphrase
// generation.
func fetchLKS(ctx *Context, g *libkb.GlobalContext, encKey libkb.GenericKey) (libkb.PassphraseGeneration, []byte, error) {
arg := libkb.APIArg{
Endpoint: "passphrase/recover",
NeedSession: true,
Args: libkb.HTTPArgs{
"kid": encKey.GetKID(),
},
}
if ctx.LoginContext != nil {
arg.SessionR = ctx.LoginContext.LocalSession()
}
res, err := g.API.Get(arg)
if err != nil {
return 0, nil, err
}
ctext, err := res.Body.AtKey("ctext").GetString()
if err != nil {
return 0, nil, err
}
ppGen, err := res.Body.AtKey("passphrase_generation").GetInt()
if err != nil {
return 0, nil, err
}
// Now try to decrypt with the unlocked device key
msg, _, err := encKey.DecryptFromString(ctext)
if err != nil {
return 0, nil, err
}
return libkb.PassphraseGeneration(ppGen), msg, nil
}
示例2: fetchLKS
// fetchLKS gets the encrypted LKS client half from the server.
// It uses encKey to decrypt it. It also returns the passphrase
// generation.
func (c *PassphraseChange) fetchLKS(ctx *Context, encKey libkb.GenericKey) (libkb.PassphraseGeneration, []byte, error) {
res, err := c.G().API.Get(
libkb.APIArg{
Endpoint: "passphrase/recover",
NeedSession: true,
Args: libkb.HTTPArgs{
"kid": encKey.GetKID(),
},
})
if err != nil {
return 0, nil, err
}
ctext, err := res.Body.AtKey("ctext").GetString()
if err != nil {
return 0, nil, err
}
ppGen, err := res.Body.AtKey("passphrase_generation").GetInt()
if err != nil {
return 0, nil, err
}
// Now try to decrypt with the unlocked device key
msg, _, err := encKey.DecryptFromString(ctext)
if err != nil {
return 0, nil, err
}
return libkb.PassphraseGeneration(ppGen), msg, nil
}