TransWikia.com

Given a PGP public key, how can I extract its PGP fingerprint in hex, using v12.0?

Mathematica Asked by ool on June 21, 2021

This is related to the question "After using GenerateAsymmetricKeyPair [], how to print the two keys in hex?" which @Sjoerd Smit kindly answered.

How can I use Mathematica v12.0 to extract the PGP fingerprint from a PGP public key, in 40 hex characters as it usually rendered?

I would like to be able to do this from other people’s public keys as well as from public keys (or for that matter private keys, which have the same fingerprint) that I have generated a moment before using GenerateAsymmetricKeyPair[].

One Answer

As far as I can find from a quick Google (but correct me if I'm wrong), the PGP fingerprint is the SHA-1 hash of the key. You can calculated it with:

pair = GenerateAsymmetricKeyPair[]
ToUpperCase @ IntegerString[
  Hash[
   pair["PublicKey"]["PublicByteArray"],
   "SHA"
   ],
  16,
  40
]

On a different note, you can check what's inside the key by using:

List @@ pair["PublicKey"]

It doesn't look like the fingerprint is generated by GenerateAsymmetricKeyPair itself.

Correct answer by Sjoerd Smit on June 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP