This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
Importing fingerprint failed. $this->gpg->geterror()
"; throw new Exception($error,false); } else { return $info['fingerprint']; } } public function set_gpg_error($error){ switch($error){ case 0: $this->gpg->seterrormode(gnupg::ERROR_EXCEPTION); break; case 1: $this->gpg->seterrormode(gnupg::ERROR_WARNING); break; default: $this->gpg->seterrormode(gnupg::ERROR_SILENT); break; } } protected function set_armor(){ // 0 is for no armor. 1 is for armor. Set the armor to 1 for sending it by e-mail. $this->gpg -> setarmor(0); } public function find_imported_key_info($data){ $info = $this->gpg->keyinfo($data); print_r($info); } } final class CryptoMessage extends Crypto { // TODO :: If there is a possibility to use GNU Anubis, it should be used instead as it hightens the // standard of security. We do not want AGPL software to have passwords in plain text. // You could alternatively, place the password in a different file I suppose. But I am not sure I like this. private $plain, $enc, $user; private $admin = 'B2232E1E36D8FC6A20A0CF8121C23A534C1EC2AB'; private $pass = '123456'; public function CryptoMessage($finger, $plain){ $this->Crypto(); $this->user = $finger; $this->plain = $plain; } public function encrypt_with_key(){ $this->gpg -> addencryptkey($this->user); // If you do not want to sign the key comment out the below line and // remove the sign part of the encryptsign(). $this->gpg -> addsignkey($this->admin, $this->pass); $this->enc = $this->gpg->encryptsign($this->plain); $this->clear_out_keys(); if($this->gpg->geterror()){ return FALSE; } else { return $this->enc; } } /* public function decrypt_with_key(){ // You should really decrypt things yourself. :P $this->gpg->adddecryptkey($this->finger,$this->pass); $text= $this->enc; $plaintext= ""; $simple = $this->gpg->decryptverify($text,$plaintext); if($this->gpg -> geterror()) { return FALSE; } else { return $plaintext; } }*/ } ?>