Using Mathematica v12.2, is it possible to call gpg (or gpg4win) and then tell it to generate an RSA key pair and to return

  • private and public PGP key blocks in standand format
  • and the 40 hex-character PGP fingerprint,

with all three then processable as Mathematica variables?

(So for example if the fingerprint did not have characters 9-12 spelling "ABC1" you could loop back and keep generating asymmetric key pairs until you found one that did have a fingerprint that met the criterion, and when you did you would have both its public key block and its private key block, as well as the "nice" fingerprint itself.)

  • 1
    $\begingroup$ Have you seen How to print PGP public key and secret key BLOCKS after generating a key pair using GenerateAsymmetricKeyPair? In addition to the solution proposed, which goes perhaps further than you need in formatting the results, but should also accomplish what you want, there is mention in the comments of the possibility to use RunProcess to just run gpg from within Mathematica. $\endgroup$
    – MarcoB
    Dec 21, 2021 at 2:26
  • $\begingroup$ Many thanks for this. Yes, I saw that question and answer. The answer goes almost the whole way, but not quite because it doesn't yield the private key block, and therefore one could get a key pair with a "nice" fingerprint but only have the public key block and not the private one. If I knew of a way to get the private key block after generating a pair with GenerateAsymmetricKeyPair then the whole problem would be solved. But that seems to be a tough ask, so I'm kinda thinking running gpg from within Mathematica is the way to go, although am unsure how to implement. $\endgroup$
    – tell
    Dec 21, 2021 at 9:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.