encryption - GnuPG: How to encrypt/decrypt files using a certain key? -
long story short, question is: how can force gnupg private/public key use when encrypting/decrypting files?
some explanation / long story
i have application must encrypt files before sending them s3.
users can download files using browsers website, in case must first decrypt files before serving them.
client side (delphi 2010): i'm going opt openpgpblackbox
server side (php 5), need figure out how encrypt/decrypt files non-interactive commands.
i installed gnupg on server, tried code:
clear_file='/full/path/my-file.zip' encrypted_file='/full/path/my-file.zip.pgp' # encrypt file /usr/bin/gpg2 --encrypt "$clear_file" # decrypt file /usr/bin/gpg2 --decrypt "$encrypted_file" but seems can't specify, in commandline, keys use.
each user have own public/private key, need able specify key use encrypt/decrypt file in question.
my question is: how can force gnupg private/public key use when encrypting/decrypting files?
the options looking are:
--default-key $name$ use $name$ default key sign with. if option not used, default key first key found in secret keyring. note -u or --local-user overrides option. --local-user $name$ -u use $name$ key sign with. note option overrides --default-key. or possibly:
--recipient $name$ -r encrypt user id $name$. if option or --hidden-recipient not specified, gnupg asks user-id unless --default-recipient given. --default-recipient $name$ use $name$ default recipient if option --recipient not used , don't ask if valid one. $name$ must non-empty. these can used specify intended recipient, e.g. public key use signing/encryption. when decrypting files gnupg automatically selects correct key if exists in current keyring, can selected --keyring option, if multiple exist. gnupg can configured fetch necessary keys keyserver if available there.
you might interested in option --batch makes sure no interactive questions asked during excecution.
i suggest read through gnupg man page. there lot of options might useful , then.
Comments
Post a Comment