singpolyma / openpgp-php

OpenPGP.php is a pure-PHP implementation of the OpenPGP Message Format (RFC 4880).
http://singpolyma.github.io/openpgp-php/
The Unlicense
179 stars 69 forks source link

Encryption #106

Closed djtimo18 closed 3 years ago

djtimo18 commented 3 years ago

Hi there,

$username = $_GET['username']; $sth = $conn->prepare("SELECT * FROM user WHERE username=:username"); $sth->bindParam(':username', $username); $sth->execute(); $row = $sth->fetch(PDO::FETCH_ASSOC); $pgp_key = $row['pgp_key']; $real_code = $row['2fa_code'];

$key = OpenPGP_Message::parse($pgp_key); $data = new OpenPGP_LiteralDataPacket($real_code); $encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message(array($data)));

I need to make an "echo $encrypted_message" how i can do it please ?

singpolyma commented 3 years ago

Please try $encrypted_message = $encrypted->to_bytes();