.KEY cryptfile/A,cryptmode/A
.BRA [
.KET ]

;
; EncryptMsg using PGP
;
; written by Peter Simons <simons@peti.GUN.de>
; modified by Ignatios Souvatzis <is@beverly.rhein.de> to be able to ask
; for passphrases etc.
; This version actually suceeds to open on Elm's screen.
; 
; $VER: EncryptMsg <is@beverly.rhein.de> 1.5 (12-Apr-95)
;

FailAt 1
Set pubscreen "`getactscreen`"
SplitHeadBody <"[cryptfile]" "T:AmiElm-Header.${process}" "T:AmiElm-Body.${process}"

If "[cryptmode]" EQ "ENCRYPT"
	RequestString RECIPIENTS "Please enter recipient(s) ID(s)..." 256
	PGP -tea "T:AmiElm-Body.${process}" <>"CON:///100/PGP/AUTO/WAIT/CLOSE/SCREEN${pubscreen}" ${RECIPIENTS}
	UnSet RECIPIENTS
Else
If "[cryptmode]" EQ "SIGN"
	PGP -tsa "T:AmiElm-Body.${process}" <>"CON:///100/PGP/AUTO/WAIT/CLOSE/SCREEN${pubscreen}" +clearsig=on
Else
If "[cryptmode]" EQ "ENCRYPT+SIGN"
	RequestString RECIPIENTS "Please enter recipient(s) ID(s)..." 256
	PGP -tesa "T:AmiElm-Body.${process}" <>"CON:///100/PGP/AUTO/WAIT/CLOSE/SCREEN${pubscreen}" ${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

;
; now copy the encrypted message back, build new message from header and body
; and get rid of our temporary files
;

Echo "*N" >"t:AmiElm-Line.${process}" NOLINE
Delete "[cryptfile]" QUIET FORCE
Join "T:AmiElm-Header.${process}" "T:AmiElm-Line.${process}" "T:AmiElm-Body.${process}.asc" as "[cryptfile]"
Delete "T:AmiElm-Body.${process}" "T:AmiElm-Header.${process}" "T:AmiElm-Body.${process}.asc" "T:AmiElm-Line.${process}" QUIET FORCE
UnSet pubscreen

;
; bye,bye
