Exporting private key returns a public key
Closed this issue · 0 comments
khushbooagarwal1 commented
Code:
# Define the parameters for the new key
key = <<-RUBY
<GnupgKeyParms format="internal">
Key-Type: RSA
Key-Length: 4096
Subkey-Type: ELG-E
Subkey-Length: 4096
Name-Real: Key Testér
Name-Comment: with some comments
Name-Email: test_generation@example.com
Expire-Date: 0
Passphrase: wadus
</GnupgKeyParms>
RUBY
# Generate PGP key
ctx = GPGME::Ctx.new
ctx.generate_key(key)
# Print
puts ctx.keys('test_generation@example.com', true).last.export(armor: true)
puts ctx.keys('test_generation@example.com', false).last.export(armor: true)
Both the puts return the same value which start with -----BEGIN PGP PUBLIC KEY BLOCK-----
.
Shouldn't first puts return a private key. Please correct me if I am missing something.