Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been searching the internet and I've come up with a lot of answers of how to store paypal API credentials(Used in Paypal Express Checkout.) They say to hash the credentials using salt. But what I don't understand is how and where to store the salt. If they get access to the salt, can't they just un-hash the credentials? That doesn't seem very secure to me. They say not to hard-code the API credentials, but any other way still seems really vulnerable. Thanks for taking the time to look at my questions. I'd really appreciate help.

share|improve this question
up vote 1 down vote accepted

Hashing them doesn't make a lot of sense, because by definition, once you hash something, you can't get it back (unhashing is not possible, but you can crack a hash using a rainbow table or brute force). Normally if you salt a hash, you store the salt along with the hash, so that it's possible to compare something to the hash; the only thing a salt does is makes rainbow attacks more difficult.

I suggest storing them in a file that is restricted somehow (readable only by root for instance). Then, your checkout service could read the file before dropping privileges, similar to how X.509 certificates are usually handled.

Hardcoding them is generally pretty vulnerable; it means that if for any reason someone can see your source, they have the credentials (eg. if the handler is set wrong).

share|improve this answer
Hey, thanks for replying! What exactly do you mean by, "dropping privilages"? And how would I go about making the file only accessible by root? – Sequence Sep 15 '12 at 0:55
You can set its owner and group to root, and set it mode 600. A service drops root privileges when it calls setuid() and setgid() to a non-root user (these are C functions); I suggest asking on stackoverflow if you want to know how to make your daemon do this. – Falcon Momot Sep 15 '12 at 0:58
So, you're saying to remove privilages when I don't need it, and give privilages when I do? I'm using Php by the way. – Sequence Sep 15 '12 at 1:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.