本文整理匯總了Golang中github.com/kisom/cryptutils/common/store.KeyStore.FindPublic方法的典型用法代碼示例。如果您正苦於以下問題:Golang KeyStore.FindPublic方法的具體用法?Golang KeyStore.FindPublic怎麽用?Golang KeyStore.FindPublic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kisom/cryptutils/common/store.KeyStore
的用法示例。
在下文中一共展示了KeyStore.FindPublic方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: keyList
func keyList(ks *store.KeyStore, cfg *config) error {
updated := time.Unix(ks.Timestamp, 0).Format(timeFormat)
fmt.Println("Key store was last updated", updated)
fmt.Printf("%d keys stored\n", len(ks.Keys))
fmt.Println("Owner public key:")
h := sha256.New()
h.Write(ks.PublicKey)
fmt.Printf("\tFingerprint: %x\n", h.Sum(nil))
if len(ks.Keys) > 0 {
fmt.Println("Key store:")
for k, v := range ks.Keys {
fmt.Printf("\t%s\n", k)
ut := time.Unix(v.Timestamp, 0)
st := time.Unix(v.SignatureTime, 0)
signer, ok := ks.FindPublic(v.KeySigner)
if !ok {
signer = "<unknown>"
}
h = sha256.New()
h.Write(v.Keys)
fmt.Printf("\t\tLast update: %s\n", ut.Format(timeFormat))
fmt.Printf("\t\t Signed at: %s\n", st.Format(timeFormat))
fmt.Printf("\t\t Signed by: %s\n", signer)
fmt.Printf("\t\tFingerprint: %x\n", h.Sum(nil))
}
}
return nil
}
示例2: importVerified
func importVerified(ks *store.KeyStore, cfg *config) error {
keyData, err := util.ReadFile(cfg.Args[0])
if err != nil {
return err
}
if cfg.Label == "self" {
cfg.Label, err = util.ReadLine("Label: ")
if err != nil {
return err
}
}
if !ks.ImportVerifiedKey(cfg.Label, keyData) {
return errors.New("verified import failed")
}
vkey, err := store.ParseVerifiedKey(keyData)
if err != nil {
return err
}
label, ok := ks.FindPublic(vkey.Signer)
if !ok {
return errors.New("invalid signer on key")
}
fmt.Printf("Imported public key signed by '%s'.\n", label)
return nil
}