• gnupg::encrypt(): get_key failed

    From Fx ROOM@21:1/5 to All on Sat May 28 10:13:32 2022
    $gpg = new gnupg(); $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

    var_dump(
    $gpg->geterror(),
    $gpg->encrypt("just a test")
    );

    OUTPUT:

    string(14) "get_key failed"
    bool(false)

    Why?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From De ongekruisigde@21:1/5 to Fx ROOM on Sat May 28 08:21:26 2022
    On 2022-05-28, Fx ROOM <naso@tata.new> wrote:
    $gpg = new gnupg(); $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

    var_dump(
    $gpg->geterror(),
    $gpg->encrypt("just a test")
    );

    OUTPUT:

    string(14) "get_key failed"
    bool(false)

    Why?

    The addencryptkey() makes a call to gnupg (do you have that installed,
    is GNUPGHOME environment variable set, is the key known to gnupg? etc.)

    https://www.php.net/manual/en/function.gnupg-addencryptkey.php

    --
    I've heard a Jew and a Muslim argue in a Damascus cafe with less
    passion than the emacs wars." [Ronald Florence <ron@18james.com> in <ueu1c4mbrc.fsf@auda.18james.com>]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Fx ROOM@21:1/5 to All on Sat May 28 13:37:36 2022
    Il 28/05/22 10:21, De ongekruisigde ha scritto:
    On 2022-05-28, Fx ROOM <naso@tata.new> wrote:
    $gpg = new gnupg();
    $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

    var_dump(
    $gpg->geterror(),
    $gpg->encrypt("just a test")
    );

    OUTPUT:

    string(14) "get_key failed"
    bool(false)

    Why?

    The addencryptkey() makes a call to gnupg (do you have that installed,
    is GNUPGHOME environment variable set, is the key known to gnupg? etc.)

    https://www.php.net/manual/en/function.gnupg-addencryptkey.php


    ????
    It is the first time I do these things.

    In any case

    $ echo $GNUPGHOME
    /tmp/key4656

    $ mkdir /tmp/key4656

    $ cat encrypt
    #!/usr/bin/php
    <?php
    $gpg = new gnupg(); $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

    var_dump(
    $gpg->geterror(),
    $gpg->encrypt("just a test")
    );

    $ ./encrypt
    string(14) "get_key failed"
    bool(false)

    Also if it serves something

    $ tree ~/.ssh
    ├── authorized_keys
    ├── id_rsa2
    ├── id_rsa.pub
    └── known_hosts

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J.O. Aho@21:1/5 to Fx ROOM on Sat May 28 23:39:54 2022
    On 28/05/2022 13.37, Fx ROOM wrote:

    In any case

    $ echo $GNUPGHOME
    /tmp/key4656

    $ mkdir /tmp/key4656

    $ cat encrypt
    #!/usr/bin/php
    <?php
    $gpg = new gnupg(); $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

    I see you just copied the example from php.net, the fingerprint has to
    belong to one of the pgp keys that is in the users default keystorage or
    one that is assigned by setting the GNUPGHOME environment variable.

    As you will never have the same fingerprint for the key as the one used
    in the example, the example will never work.


    What you need to do is to create a new pgp key with gpg and then use the fingerprint for the public key as the argument for your addencryptkey().



    Also if it serves something

    $ tree ~/.ssh
    ├── authorized_keys
    ├── id_rsa2
    ├── id_rsa.pub
    └── known_hosts

    No, that ain't the same as pgp keys (the above are ssl), I would suggest
    you take a loot at the gpg man page, just type in your terminal: man gpg
    or you can visit the following page: https://manpages.org/gpg


    --

    //Aho

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Fx ROOM@21:1/5 to All on Sun May 29 12:07:05 2022
    Il 28/05/22 23:39, J.O. Aho ha scritto:
    What you need to do is to create a new pgp key with gpg and then use the fingerprint for the public key as the argument for your addencryptkey().

    //-----BEGIN SCRIPT-----

    /*
    * Installazione estensione
    * $ sudo apt install php-gnupg
    *
    * Generazione chiave
    * $ gpg --gen-key
    */

    $gpg = new gnupg();
    $key = file_get_contents(__DIR__ . "/../etc/key");
    $gpg->addencryptkey($key);

    var_dump(
    $gpg->geterror(),
    $encrypted_text = $gpg->encrypt("just a test"),
    $gpg->decrypt($encrypted_text),
    );
    //-----END SCRIPT-----

    bool(false)
    string(699) "-----BEGIN PGP MESSAGE-----

    hQGMA950B1qyHrK/AQwAm0nogiPFkFzBnYP5CjDUipMkzSXmu0ti9nh1/9gsruZM HIeehoDQZIPTteY29PqH4t/Ijy59Chl3+CW8Lz1lNycAz0kMDeTRgkxIO7jG7GiQ BRQ4qH67epZZqAx1xgMRPh/NOR11sqAvARnVUI/UxWUtcLvtjH7huMFSDcyl1+1k 3fpc2wu+u1wBMWvWIsZ7rreJNtSxgbMzZ9/yX8ykORFbDr945CaOxBtejkfPZLmi 3vpjfEiUWimlU8X2C2BLf5VU2rVVJpyp0ZkUJ/dgfNyyoDBUge6jLZkpojHtZBHd lIdym7BjpAAOCUGWxDEUPZjJyk1Oc3B/j0svC+vymtXpm1VBXVjnGheuHgREV2+c 05a7P9KOhnq/DQ02jMGa/MpMnRaxjwd/rshSlh4PfY6spdLeETglhXn/3iNBpSRE M42jgYA1h4wb4JyWoojiGgkTR7I3"...
    string(11) "just a test"

    Good!!!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)