| 
<?
include("gnupgp.class.php");
 
 $gpg = new gnugpg;
 $gpg->userName = $userName;
 $gpg->userEmail = $userEmail;
 $gpg->recipientName = $recipientName;
 $gpg->recipientEmail = $recipientEmail;
 $gpg->message = $message;
 
 function Tab_List($key_Array){
 echo "<table border=1>";
 echo "<tr><th>Type</th><th>Trust</th><th>Length</th><th>Algor.</th>";
 echo "<th>KeyID</th><th>Creation</th><th>Expiration</th><th>Local ID</th>";
 echo "<th>Ownertrust</th><th>User ID</th><th>???</th><th>???</th></tr>";
 for($i=2; $i < count($key_Array); $i++){
 $tmp = explode(":",$key_Array[$i]);
 echo "<tr>";
 echo "<td>".$tmp[0]."</td>";            //type
 echo "<td>".$tmp[1]."</td>";            //trust
 echo "<td>".$tmp[2]."</td>";            //length
 echo "<td>".$tmp[3]."</td>";            //algorithm
 echo "<td>".$tmp[4]."</td>";            //KeyID
 echo "<td>".$tmp[5]."</td>";            //Creation date
 echo "<td>".$tmp[6]."</td>";            //Expiration date
 echo "<td>".$tmp[7]."</td>";            //Local ID
 echo "<td>".$tmp[8]."</td>";            //Ownertrust
 echo "<td>".htmlspecialchars($tmp[9])."</td>";    //User ID
 echo "<td>".$tmp[10]."</td>";            // ???
 echo "<td>".$tmp[11]."</td>";            // ???
 echo "</tr>";
 if($tmp[0] == "sub"){
 echo "<tr><td colspan=\"12\"> </td></tr>";
 }
 }
 echo "</table>";
 echo "<br><br>";
 echo "<font size=-1>1. Field:  Type of record<br>
 <UL>
 <LI>pub = public key
 <LI>sub = subkey (secondary key)
 <LI>sec = secret key
 <LI>ssb = secret subkey (secondary key)
 <LI>uid = user id (only field 10 is used)
 <LI>fpr = fingerprint: (fingerprint is in field 10)
 <LI>pkd = public key data (special field format, see below)
 </UL>
 </font><br>";
 echo "<font size=-1>2. Field:  A letter describing the calculated trust. This is a single
 letter, but be prepared that additional information may follow
 in some future versions. (not used for secret keys)<br>
 <UL>
 <LI>o = Unknown (this key is new to the system)
 <LI>d = The key has been disabled
 <LI>r = The key has been revoked
 <LI>e = The key has expired
 <LI>q = Undefined (no value assigned)
 <LI>n = Don't trust this key at all
 <LI>m = There is marginal trust in this key
 <LI>f = The key is full trusted.
 <LI>u = The key is ultimately trusted; this is only used for keys for which the secret key is also available.
 </UL>
 </font><br>";
 echo "<font size=-1>3. Field:  length of key in bits.</font><br><br>";
 echo "<font size=-1>4. Field:  Algorithm:<br>
 <UL>
 <LI>1 = RSA
 <LI>16 = ElGamal (encrypt only)
 <LI>17 = DSA (sometimes called DH, sign only)
 <LI>20 = ElGamal (sign and encrypt)
 </UL>
 </font><br>";
 echo "<font size=-1>5. Field:  KeyID.</font><br><br>";
 echo "<font size=-1>6. Field:  Creation Date (in UTC).</font><br><br>";
 echo "<font size=-1>7. Field:  Key expiration date or empty if none.</font><br><br>";
 echo "<font size=-1>8. Field:  Local ID: record number of the dir record in the trustdb.
 This value is only valid as long as the trustdb is not
 deleted. You can use \"#<local-id> as the user id when
 specifying a key. This is needed because keyids may not be
 unique - a program may use this number to access keys later.</font><br><br>";
 echo "<font size=-1> 9. Field:  Ownertrust (primary public keys only)
 This is a single letter, but be prepared that additional
 information may follow in some future versions.</font><br><br>";
 echo "<font size=-1>10. Field:  User-ID.  The value is quoted like a C string to avoid
 control characters (the colon is quoted \"\x3a\").</font><br><br>";
 echo "<font size=-1>11. Field: ????.</font><br><br>";
 echo "<font size=-1>12. Field: ????.</font><br><br>";
 }
 
 switch ($action){
 case "gen_key":
 $result = $gpg->gen_key($userName, $comment, $userEmail, $passphrase);
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>The key was generated sucessful.</h3>";
 }
 break;
 case "list_key":
 $result = $gpg->list_keys();
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>This is the keys on the <font color=red>".$gpg->userName."</font>'s keyring</h3><br>";
 Tab_List($gpg->keyArray);
 }
 break;
 case "export_key":
 $result = $gpg->export_key();
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>This is the <font color=red>".$gpg->userEmail."</font>'s Public Key</h3><br>";
 echo "<form><TEXTAREA rows=\"30\" cols=\"80\">".$gpg->public_key."</TEXTAREA>";
 }
 break;
 case "import_key":
 $result = $gpg->import_key($key);
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>The keys was imported successful.</h3><br>";
 $result = $gpg->list_keys();
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>This is the keys on the <font color=red>".$gpg->userEmail."</font>'s keyring</h3><br>";
 Tab_List($gpg->keyArray);
 }
 }
 break;
 case "remove_key":
 if(!empty($keyID)){
 $key = $keyID;
 } elseif (!empty($emailID)){
 $key = $emailID;
 } else {
 $key = $nameID;
 }
 
 $result = $gpg->remove_key($key);
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>The key was successful removed.</h3><br>";
 $result = $gpg->list_keys();
 if(!$result){
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>This is the keys on the <font color=red>".$gpg->userEmail."</font>'s keyring</h3><br>";
 Tab_List($gpg->keyArray);
 }
 }
 case "encrypt_Msg":
 if(empty($userEmail)){
 echo "The \"From User:\" can't be empty!";
 exit();
 }
 if(empty($recipientEmail)){
 echo "The \"To Email:\" can't be empty!";
 exit();
 }
 $result = $gpg->encrypt_message();
 if (!$result) {
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>The message was successful encrypted!</h3><br>";
 echo "<form><TEXTAREA rows=\"20\" cols=\"80\">".$gpg->encrypted_message."</TEXTAREA></form>";
 }
 break;
 case "decrypt_Msg":
 if(empty($userEmail)){
 echo "The \"Name\" can't be empty!";
 exit();
 }
 if(empty($passphrase)){
 echo "The \"Passphrase\" can't be empty!";
 exit();
 }
 if(empty($message)){
 echo "The \"Message\" can't be empty!";
 exit();
 }
 $result = $gpg->decrypt_message($message, $passphrase);
 if (!$result) {
 echo $gpg->error;
 exit();
 } else {
 echo "<h3>The message was successful decrypted!</h3><br>";
 echo "<form><TEXTAREA rows=\"20\" cols=\"80\">".$gpg->decrypted_message."</TEXTAREA></form>";
 }
 break;
 
 
 
 
 
 
 
 } // end switch $action
 
 ?>
 
 |