ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Exporting private key returns a public key #172

Closed khushbooagarwal1 closed 1 year ago

khushbooagarwal1 commented 1 year ago

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.