#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Using Gnupg to encrypt credit card details


    I know it is difficult to answer me when the questions to ask is not even simple. I will explain.

    I have a provider where I run PHP. My boss needs to store credit card details in the database. But the English law requires them to be encrypted. I want to use gnupg to encrypt the credit card details.
    Then I look on php.net and there is a function (among others) called gnupg_init(). This seems to provide all that I want. But when I use it it cannot find the function.
    I also read that the gnupg library is available as a PECL. This PECL stuff is all new to me.
    I just do not know what to do?
    Do I download the library? I think so. But where do I place it?
    Do I upload it next to my php programs on the server?
    Do I have to change something in the php.ini file?

    Can anybody give me an idea as to what I need to do? It is all a big riddle to me now.
    Always keep in mind that I want to achieve the following:
    - I receive credit card details automatically in my php program. This already works.
    - I now store them in the database (already works) but I would like to encrypt them using gnupg before doing that. I know I need a public key from the person that will eventually decrypt it for this.

    Not too much to ask I think. Should not be too difficult, but it is.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    This explains how to download and install PECL extensions.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Hmm That might be very obvious for you, but it does not help me. I had already found this.
    Can you give me some steps to take.
    Do you think it possible what I want?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    Then I don't understand your question. What part of the installation instructions do you not understand? Quote the section and I'll try to explain.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    That is the very problem.
    I have no clue as to where to start.

    I never installed a PECL and I do not know how.
    I want to run the gnupg_* functions in PHP.
    If I look at phpinfo(), I see no gnupg there.
    Does that mean my provider does not offer this?
    Or can I install it myself?

    I take it that the provider does not like it when several users install this or is this normal behaviour?

    Is it this I must run?
    $ pecl install {package}

    It is all so new to me.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    Start with the section titled "Downloading PECL extensions."
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    so I do the command line command:
    pecl download gnupg

    And that is enough?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    If you have the pecl command installed yes. That will download the file then you follow the next steps in the instructions. If you don't have the pecl command installed then install it first. How you install it depends on your OS.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    I ran the command on the provider's server but it produced and error. Probably there is no pecl command there.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    If you don't own the server or have admin (sudo) privileges then it won't matter as you will not be able to install software anyway. If that is the case then you need to ask your systems admin to install it for you.

    If that is not possible then you are going to have your work cut out for you. You will probably have to install GPG in your own workspace, and program your page to encrypt/decrypt the data as necessary with 'system' calls rather than PHP extensions.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    I do not have rights on the server and I figured that was going to be the problem all along. I had hoped there was a PHP class that I could upload in my workspace and run from there.

    I think I give up or maybe you have other ideas.
    Thanks for you help
    Eric from Spain
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,601
    Rep Power
    595
    As I suggested, you can install GPG in your own workspace and write the pages using 'system' to encrypt/decrypt the data.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  24. #13
  25. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    The mcrypt extension is a better way of doing this. There's a good chance that it is already installed on your host, but if it isn't, you won't be able to install it yourself.

    There is a pure-PHP library called phpseclib that can perform RSA encryption. It will be slow, but you can use that as a fall back if mcrypt is not available.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    7
    Rep Power
    0

    mcrypt...openssl


    GnuPG is a fine product but for this, you may be better off using the PHP OpenSSL functions if you would like to do RSA encryption.

    If you are looking for a solution for symmetrical encryption mcrypt would fit the bill.

IMN logo majestic logo threadwatch logo seochat tools logo