|
In general, if the program needs to read the password as its original form from this file, there is not a secure way to store it. (You need to rely on filesystem permissions.) On the other hand, if the program needs only to verify that a typed password matches the one "stored" in the file, you can do it by storing a hash of the original in the file. MD5 and SHA1 are two algorithms you could use to do this; they'll be in most any crypto library. You can use crypt(3), but it's not very strong.
If the point of this is just to keep your kid sister from reading the data, and not actually to be secure, you can do some trivial transform to the password before storing it, e.g. memfrob(3).
|