Question Locked

How to programitically create password protected file

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

Thanks
Debashree

3 replies

by bizzo

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

If this isn't an option, you could try 7zip (http://www.7-zip.org/download.html), 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.

by kingbackwards

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

EXAMPLE:
To encrypt
[pre]7za a -tzip protected.zip somefile.txt -ppassword[/pre]

To extract
[pre]7za x protected.zip[/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.

This discussion is closed to new replies.