How to programitically create password protected file

By chattede ·
Hi All,

Need you expert suggestion if anyone know how to programitically password protect any file ?

I have a project where I have to send a extact file which should be password protected as the vendor don't support PGP encryption.

Please help me, I am using unix script to extract the data.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Depends what the customer has

by Bizzo In reply to How to programitically cr ...

If they haven't got PGP, then you could try GnuPG which is Linux/Windos/Mac supported (, free, but whoever you're sending to will need it as well.

If this isn't an option, you could try 7zip (, again, there's versions for windows/linux etc to create a zip file which is password protected. This again is free and has a command line version which means you can do it programatically.

Collapse -

Two options I can think of.

by Kingbackwards In reply to How to programitically cr ...

1. 7zip, you might need to install the p7zip package, and you can make a password protected zip file.

To encrypt
[pre]7za a -tzip somefile.txt -ppassword[/pre]

To extract
[pre]7za x[/pre]
(then type the password "password" when promoted, or use the -p option to skip the prompt)

2. Openssl, its installed on most linux distros and macs. There are several encryption options depending on the cyphyer you want, I used des3 for the example since its easy to type :)

To encrypt a file:
[pre]openssl des3 -a -salt -k password -in normalfile.txt -out encryptedfile.txt[/pre]

To decrypt the file:
[pre]openssl des3 -d -a -k password -in encryptedfile.txt -out normalfile.txt[/pre]

You can remove the -k and will be prompted to type the password on the fly.

Related Discussions

Related Forums