[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: password protection of a file



Flo a écrit le 16/01/05 13:25 :
thanx a lot,

the trouble is that i want to use the command into a script.
Unfortunately gpg -c and zip -e ask for an user input for the password :-(


At least, zip with options -e and -P (I think) can do that.
Take a look at man zip.
But others have told you how weak zip's encryption is.

As far as gpg is concerned, I just got this idea by reading man gpg.
I don't know if there is any easier way.

Suppose you want to encrypt the file named "secret.txt" with passphrase "nobody knows this" you can do
	echo nobody knows this | gpg -c --passphrase-fd 0 secret.txt
this will create a file "secret.txt.gpg"

To decrypt it into a file named "secret2.txt" you can do
	echo nobody knows this | gpg  --passphrase-fd 0
	-o secret2.txt -d secret.txt.gpg
(all in one single line of course).

Of course, having the password written in the script file is totally unsecure; I think encrypting a file in such a way is totally pointless.
Really I can't think of a single reason to do it.
(If you have one, I'm curious to know !)

On the other hand, having the script prompt you for the password that you would put in a variable and use it in something like
	echo "$varpass" | gpg -c --passphrase-fd 0 "$file"
could be a way to encrypt many files without the need to enter the password for each of them.

Beware that I am no specialist of these matters !

--
Eddy
         "La notion de passoire est indépendante de la notion de trou."
		                                 Les Shadoks



Reply to: