Using PHP-GPG with Wordpress -


i'm working on implementation, should send every outgoing mail wordpress installation gpg encrypted.

i built small plugin tutorial tim nash, , used php-gpg lib jason hinkle. when send email wordpress 4.3, pgp-encrypted mail, can't open it, because wp / plugin uses wrong public key. checked out, , pasted right key in user wp-profile, ... nothing: wrong key. have ideas?

<?php /** @package    php-gpg::gpg */  /** seed rand */ list($gpg_usec, $gpg_sec) = explode(' ', microtime()); srand((float) $gpg_sec + ((float) $gpg_usec * 100000));  /**  * @package    php-gpg::gpg  */ class gpg_utility {      static function starts_with($haystack, $needle)     {         return $needle === "" || strpos($haystack, $needle) === 0;     }      static function b0($x) {         return ($x & 0xff);     }      static function b1($x) {         return (($x >> 0x8) & 0xff);     }      static function b2($x) {         return (($x >> 0x10) & 0xff);     }      static function b3($x) {         return (($x >> 0x18) & 0xff);     }      static function zshift($x, $s) {         $res = $x >> $s;          $pad = 0;         ($i = 0; $i < 32 - $s; $i++) $pad += (1 << $i);          return $res & $pad;     }      static function pack_octets($octets)     {         $i = 0;         $j = 0;         $len = count($octets);         $b = array_fill(0, $len / 4, 0);          if (!$octets || $len % 4) return;          ($i = 0, $j = 0; $j < $len; $j += 4) {             $b[$i++] = $octets[$j] | ($octets[$j + 1] << 0x8) | ($octets[$j + 2] << 0x10) | ($octets[$j + 3] << 0x18);          }          return $b;       }      static function unpack_octets($packed)     {         $j = 0;         $i = 0;         $l = count($packed);         $r = array_fill(0, $l * 4, 0);          ($j = 0; $j < $l; $j++) {             $r[$i++] = gpg_utility::b0($packed[$j]);             $r[$i++] = gpg_utility::b1($packed[$j]);             $r[$i++] = gpg_utility::b2($packed[$j]);             $r[$i++] = gpg_utility::b3($packed[$j]);         }          return $r;     }         static function hex2bin($h)     {         if(strlen($h) % 2) $h += "0";          $r = "";         for($i = 0; $i < strlen($h); $i += 2) {             $r .= chr(intval($h[$i], 16) * 16 + intval($h[$i + 1], 16));         }          return $r;     }      static function crc24($data)     {         $crc = 0xb704ce;          for($n = 0; $n < strlen($data); $n++) {             $crc ^= (ord($data[$n]) & 0xff) << 0x10;             for($i = 0; $i < 8; $i++) {                 $crc <<= 1;                 if($crc & 0x1000000) $crc ^= 0x1864cfb;             }                }          return             chr(($crc >> 0x10) & 0xff) .             chr(($crc >> 0x8) & 0xff) .             chr($crc & 0xff);     }      static function s_random($len, $textmode)     {         $r = "";         for($i = 0; $i < $len;)         {             $t = rand(0, 0xff);             if($t == 0 && $textmode) continue;             $i++;              $r .= chr($t);         }          return $r;     }      static function c_random() {         return round(rand(0, 0xff));     }  } ?> 


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -