<?php $plaintext_body = 'Some sensitive order data'; $recipient = '*****@*****.**'; $g = gnupg_init(); gnupg_seterrormode($g, GNUPG_ERROR_WARNING); // Fingerprint of the recipient's key $a = gnupg_addencryptkey($g, "5495F0CA9C8F30A9274C2259D7EBE8584CEF302B"); // Fingerprint of the sender's key $b = gnupg_addsignkey($g, "520D5FC5C85EF4F4F9D94E1C1AF1F7C5916FC221", "passphrase"); $encrypted_body = gnupg_encryptsign($g, $plaintext_body); mail($recipient, 'Web Site Order', $encrypted_body);
function login($sig, $key, $text) { # Set this to a private directory outside of the webroot. Make sure the permissions are correct putenv("GNUPGHOME=/var/www/clients/client0/web5/private/.gnupg"); $res = gnupg_init(); gnupg_seterrormode($res, GNUPG_ERROR_WARNING); gnupg_import($res, $key); $info = gnupg_verify($res, $text, $sig); $key = gnupg_keyinfo($res, $info[fingerprint])[0]; $id = $key["subkeys"][0]["keyid"]; $uid = $key["uids"][0]; print " KeyId: " . $id; var_dump($uid); }