.KEY cryptfile/A,cryptmode/A
.BRA {
.KET }

;
; EncryptMsg using PGP
;
; written by Peter Simons <simons@peti.GUN.de>
;
; [you need "AmigaPGP 2.3a.3" or higher, -amk]
;

FailAt 1

SplitHeadBody <"{cryptfile}" T:AmiElm-Header.$process T:AmiElm-Body.$process

If "{cryptmode}" EQ "ENCRYPT"
        RequestString RECIPIENTS "Please enter recipient(s) ID(s)..." 256
        PGP -ftea <T:AmiElm-Body.$process >"{cryptfile}.asc" `Echo $RECIPIENTS`
        UnSet RECIPIENTS
Else
If "{cryptmode}" EQ "SIGN"
        PGP -ftsa <T:AmiElm-Body.$process >"{cryptfile}.asc" +clearsig=on
Else
If "{cryptmode}" EQ "ENCRYPT+SIGN"
        RequestString RECIPIENTS "Please enter recipient(s) ID(s)..." 256
        PGP -ftesa <T:AmiElm-Body.$process >"{cryptfile}.asc" `Echo $RECIPIENTS`
        UnSet RECIPIENTS
Else
	Echo "elm: Encrypt mode *"{cryptmode}*" not supported by *"EncryptMsg*" script!"
	Echo "elm: WARNING! Mail not modified, sending mail NOT encrypted ..."
	Delete T:AmiElm-Header.$process T:AmiElm-Body.$process QUIET FORCE
	Quit
EndIf
EndIf
EndIf

;
; build new message from header and body
; and get rid of our temporary files
;

Delete {cryptfile} QUIET FORCE
Rename T:AmiElm-Header.$process "{cryptfile}"
Echo "*N" >>"{cryptfile}" NOLINE
Type "{cryptfile}.asc" >>"{cryptfile}"
Delete "{cryptfile}.asc" T:AmiElm-Header.$process T:AmiElm-Body.$process QUIET FORCE

