Esempio n. 1
0
 public function encryptSecret($public_key)
 {
     // Set GnuPG homedir to /tmp
     putenv("GNUPGHOME=/tmp");
     // Create new GnuPG instance
     $gpg = new gnupg();
     // Import given public key
     $key = $gpg->import($public_key);
     // Add imported key for encryption
     $gpg->addencryptkey($key['fingerprint']);
     // Encrypt the secret to a PGP message
     $enc = $gpg->encrypt($this->secret);
     // Clear the encryption key
     $gpg->clearencryptkeys();
     // Return  the PGP message
     return $enc;
 }