Created
August 15, 2013 12:38
-
-
Save marete/6240512 to your computer and use it in GitHub Desktop.
Print out every imaginable detail about the keys in you OpenPGP keyring as a JSON array. Call it like this: `keyring ~/.gnupg/pubring.gpg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
_ "code.google.com/p/go.crypto/md4" | |
"code.google.com/p/go.crypto/openpgp" | |
_ "code.google.com/p/go.crypto/ripemd160" | |
_ "crypto/md5" | |
_ "crypto/sha1" | |
_ "crypto/sha256" | |
_ "crypto/sha512" | |
_ "crypto/sha512" | |
"encoding/json" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { | |
if len(os.Args) != 2 { | |
fmt.Fprintf(os.Stderr, "Usage: %s <keyring>\n", os.Args[0]) | |
os.Exit(1) | |
} | |
f, err := os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
el, err := openpgp.ReadKeyRing(f) | |
if err != nil { | |
log.Fatal(err) | |
} | |
b, err := json.MarshalIndent(el, "", "\t") | |
if err != nil { | |
log.Fatal(err) | |
} | |
os.Stdout.Write(b) | |
fmt.Println("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment