Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:55:06+00:00 2026-05-25T13:55:06+00:00

I really want to go about this securely, as there is customer data involved.

  • 0

I really want to go about this securely, as there is customer data involved.

I am using GNUPG via the command line because I am on shared hosting, and the PHP class is not available. So my code is as follows:

putenv("GNUPGHOME=/home/me/.gnupg");

$gpg = '/usr/bin/gpg';
$gpgrecipient = 'email';
$mailrecp = 'email';
$plain = 'Here is the encrypted Text Here is the encrypted Text Here is the
    encrypted Text Here is the encrypted Text Here is the encrypted Text Here is the
    encrypted Text Here is the encrypted Text Here is the encrypted Text Here is the  
    encrypted Text';



$encrypted = shell_exec("echo {$plain} | {$gpg} --no-auto-check-trustdb --lock-never -e -a -r {$gpgrecipient} ");

So, how do I go about escaping $plain, while preserving data integrity?

If I just use escapeshellcmd() it tends to mess up formatting.

I am a bit leery of saving anything out to a file because it is sensitive data on shared hosting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:55:06+00:00Added an answer on May 25, 2026 at 1:55 pm

    I don’t know php very well, but have you considered using proc_open rather than shell_exec? It seems cleaner than invoking a shell command to echo the input and pipe it to gpg.

    But if you’d rather use proc_open, consider using printf rather than echo -n; it has better defined behavior. For example (untested):

    $encrypted = shell_exec("printf '%s' '{$plain}' | {$gpg} ...`
    

    With echo, you run the risk that the echo command (which could be either a shell built-in or the /bin/echo command) might interpret some of its arguments as something other than strings to be printed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really want Resharper to format my line-wrapped ternaries in this way return navigator.IsTerminating
I'm using Python/Django, but this is more about the data model and how I
I know about the ADODB.Stream object . But what I really want is a
For my assignment , I want to know about common compiler list? I really
I am really confused about this.I have set the background color of the whole
I've seen a lot of questions about this subject but i'm really not happy
Before anything, this is not necessarily a question.. But I really want to know
This really is an architectural question. I feel like I'm going about this the
I really want to write .NET apps that run on any platform (PC, Linux
I really want to get the google Calendar Api up an running. I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.