3 require_once dirname(__FILE__).'/../lib/openpgp.php';
4 require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
6 $rsa = new \phpseclib\Crypt\RSA();
7 $k = $rsa->createKey(512);
8 $rsa->loadKey($k['privatekey']);
10 $nkey = new OpenPGP_SecretKeyPacket(array(
11 'n' => $rsa->modulus->toBytes(),
12 'e' => $rsa->publicExponent->toBytes(),
13 'd' => $rsa->exponent->toBytes(),
14 'p' => $rsa->primes[2]->toBytes(),
15 'q' => $rsa->primes[1]->toBytes(),
16 'u' => $rsa->coefficients[2]->toBytes()
19 $uid = new OpenPGP_UserIDPacket('Test <test@example.com>');
21 $wkey = new OpenPGP_Crypt_RSA($nkey);
22 $m = $wkey->sign_key_userid(array($nkey, $uid));
24 // Serialize private key
27 // Serialize public key message
29 $pubm[0] = new OpenPGP_PublicKeyPacket($pubm[0]);
31 $public_bytes = $pubm->to_bytes();