GPG = new GnuPG(['home-dir' => $tmpPath]); $keyData = file_get_contents($keyFile); $this->GPG->import($keyData); if (!empty($fingerprint)) { $result = $this->GPG->addsignkey($fingerprint, $passphrase); if ($result == false) { return false; } else { $this->GPG->setsignmode(GNUPG_SIG_MODE_NORMAL); return true; } } } public function sign($data) { if ($this->GPG == null) { return false; } $data = $this->GPG->sign($data); return $data; } public function verify($data) { $verified = ""; $info = $this->GPG->verify($data, false, $verified); $result = array("data" => $verified, "message" => $info); if ($info == false) { $result['message'] = "Signature Verification Failed."; $result['data'] = false; return $result; } else { return $result; } } }