Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:56:57+00:00 2026-06-11T11:56:57+00:00

There is a PHP extension port of the gnupg PGP library. However, I’m having

  • 0

There is a PHP extension port of the gnupg PGP library. However, I’m having a hard time finding examples that explain how to use the library.

How do you properly create keys for application users, and then use them to encrypt/decrypt text using the GnuPG library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:56:58+00:00Added an answer on June 11, 2026 at 11:56 am

    See this URL it is very help full to you. Download example and try it.

    https://github.com/singpolyma/openpgp-php

    Or Try it:-

    You can download lib/openpgp.php and lib/openpgp_crypt_rsa.php files in above the URL.

    examples/keygen.php

    <?php
    
    require dirname(__FILE__).'/../lib/openpgp.php';
    require dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
    
    $rsa = new Crypt_RSA();
    $k = $rsa->createKey(512);
    $rsa->loadKey($k['privatekey']);
    
    $nkey = new OpenPGP_SecretKeyPacket(array(
       'n' => $rsa->modulus->toBytes(),
       'e' => $rsa->publicExponent->toBytes(),
       'd' => $rsa->exponent->toBytes(),
       'p' => $rsa->primes[1]->toBytes(),
       'q' => $rsa->primes[2]->toBytes(),
       'u' => $rsa->coefficients[2]->toBytes()
    ));
    
    $uid = new OpenPGP_UserIDPacket('Test <test@example.com>');
    
    $wkey = new OpenPGP_Crypt_RSA($nkey);
    $m = $wkey->sign_key_userid(array($nkey, $uid));
    
    print $m->to_bytes();
    

    examples/sign.php

    <?php
    
    require dirname(__FILE__).'/../lib/openpgp.php';
    require dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
    
    /* Parse secret key from STDIN, the key must not be password protected */
    $wkey = OpenPGP_Message::parse(file_get_contents('php://stdin'));
    $wkey = $wkey[0];
    
    /* Create a new literal data packet */
    $data = new OpenPGP_LiteralDataPacket('This is text.', array('format' => 'u', 'filename' => 'stuff.txt'));
    
    /* Create a signer from the key */
    $sign = new OpenPGP_Crypt_RSA($wkey);
    
    /* The message is the signed data packet */
    $m = $sign->sign($data);
    
    /* Output the raw message bytes to STDOUT */
    echo $m->to_bytes();
    
    ?>
    

    examples/verify.php

    <?php
    
    require dirname(__FILE__).'/../lib/openpgp.php';
    require dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
    
    /* Parse public key from STDIN */
    $wkey = OpenPGP_Message::parse(file_get_contents('php://stdin'));
    $wkey = $wkey[0];
    
    /* Parse signed message from file named "t" */
    $m = OpenPGP_Message::parse(file_get_contents('t'));
    
    /* Create a verifier for the key */
    $verify = new OpenPGP_Crypt_RSA($wkey);
    
    /* Dump verification information to STDOUT */
    var_dump($verify->verify($m));
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any PHP libraries that provide similar functionality to Kenneth Reitz's clint library
EDIT: Yields that there is already new PHP framework written as extension. http://code.google.com/p/yafphp ,
There used to be a PHP extension that could load Java libraries and call
Is there a function and/or object and/or extension in PHP that will let you
There is my site For SEO I have removed the .php extension from all
Is there any php function in our time, which generates absolutely unique, random string?
Is there any php fractal image generating library like stackoverflow's default avatar ? I
Is there a php function that someone can use to automatically detect if an
I used php extension pspell to identify existence of english words, however, some combinations
Hi I was just wondering if there is any way that using a .php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.