i don't know of a script which will do what you described off-hand, but it seems likely that you could accomplish what you described w/o much trouble using Frank Tobin's GnuPG::Interface perl module. i believe it's available via cpan.