Gnupg in PHP5 does not print in browser, but works in terminal?

Asked

Viewed 42 times

1

I’m having a problem in PHP that I’ve never seen before, I’m using the Gnupg class to generate encrypted messages, however I can’t use in browser, I was wondering why but I can’t come to the conclusion, maybe security, the generated variable is always empty in the browser, but in the terminal is printed perfectly.

Code:

<?php

  $text = "ISSO É UM TESTE";

  $enc = encrypt($text);

  print $enc;

  function encrypt($text){
      $gpg = new gnupg();
      $gpg->addencryptkey("KEY_AQUI");
      $enc = $gpg->encrypt("$text");
      return $enc;
  }

?>

In the browser, it just doesn’t work, the page is empty, in the terminal with results, as in the image below:

O texto é criptografado normalmente

  • 1

    Good afternoon, post the entire code of the index.php you executed in the terminal (if you can simplify), read this: http://answall.com/help/mcve - I am waiting for you to edit your question and put the code in it, I’m sure it will take my comment as a constructive criticism :)

  • Thank you for answering, well, the code is basically what I had shown, I made the changes, the code I have so far is this.

  • gnupg is imported as? Or this class is provided with a php extension extension=foo.so?

  • yes, it comes from an extension (./usr/lib/php5/20131226/gnupg.so), I normally installed it from apt (linux)

  • Did you download it from the Ubuntu repository? Or did you add a repository? My Debian virtual machine is on another PC, but as soon as possible I will test.

  • downloaded by the same official (debian)

  • Cool, I don’t know when I’ll be able to test it, but as soon as possible I’ll give you a feedback

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.