php - Encrypted message doesn't appear on page -
i'm using pgp-2fa , on local working great. i've trying on host doesn't show encrypted message.
the way working is
$key = db::table('users')->select('pgp_key')->where('user_id', '=', $data['user_id'])->first(); $pgp = new pgp_2fa(); $msg = ''; $pgp->generatesecret(); $enc = $pgp->encryptsecret($key->pgp_key); return view::make('users.auth', ['enc'=> $enc]);
here i've selected users public pgp key profile , encrypt message must decrypt private key.
when var_dump($enc);
i've received
bool(false)
and var_dump($pgp);
object(pgp_2fa)#336 (1) { ["secret":"pgp_2fa":private]=> string(15) "603893251905515" }
which correct string(15) "603893251905515"
. problem in view don't see $enc
because it's returning bool(false)
.
this have in view
<pre>{{ $enc }}</pre>
again: working great on local can't figured out why doesn't work here. appreciated.
update:
var_dump($key);
return correct key database user. i'm not copied whole key because long:
object(stdclass)#353 (1) { ["pgp_key"]=> string(1756) "-----begin pgp public key block----- version: gnupg v1 m............
update2: pgp-2fa.php
class pgp_2fa { private $secret; // generate safe hash of unencrypted secret, push session , save unencrypted secret locally public function generatesecret(){ // generate unencrypted secret $secret = generatesecretkey(); // hash secret bcrypt $secret_hash = password_hash($secret, password_bcrypt); // save within session session::set('pgp-secret-hash', $secret_hash); $this->secret = $secret; } // encrypt secret pgp public key public function encryptsecret($public_key){ // set gnupg homedir /tmp putenv("gnupghome=/tmp"); // create new gnupg instance $gpg = new gnupg(); // import given public key $key = $gpg->import($public_key); // add imported key encryption $gpg->addencryptkey($key['fingerprint']); // encrypt secret pgp message $enc = $gpg->encrypt($this->secret); // clear encryption key $gpg->clearencryptkeys(); // return pgp message return $enc; } }
Comments
Post a Comment