I want to store a password in a config file, something as below. I want my scripts to use it. But when The config file is opened using vi or more or cat, it should display as 'XXXXX' but not its actual value.
PASSWORD=XXXXXXXXXXXX
On
You can follow the UNIX/Linux way. Which mean you can store the hash of the password in config file, something like:
LOGIN=foobar
PASSWORD=6b3a55e0261b0304143f805a24924d0c1c44524821305f31d9277843b8a10f4e
lorem
ipsum
doloris
and when user/program want to use it provide the password password and a program, script do sha256 over this string and compare the result with the value, stored in config
This above is just a example and you should implement additional measures to avoid rainbow tables attack for example.
A simple implementation:
Input file
Your cat implementation with required feature:
then
Output