Add SHA256 fingerprint utils and helpers (#41)

This commit is contained in:
wussler 2020-04-07 14:59:25 +02:00 committed by GitHub
parent c8b7e87135
commit 3c79f40acb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 3 deletions

View file

@ -1,6 +1,8 @@
package helper
import (
"encoding/json"
"github.com/ProtonMail/gopenpgp/v2/crypto"
)
@ -65,3 +67,12 @@ func EncryptAttachment(plainData []byte, fileName string, keyRing *crypto.KeyRin
}
return decrypted, nil
}
func GetJsonSHA256Fingerprints(publicKey string) ([]byte, error) {
key, err := crypto.NewKeyFromArmored(publicKey)
if err != nil {
return nil, err
}
return json.Marshal(key.GetSHA256Fingerprints())
}