-(defun netrc-encrypt (plain-file encrypted-file)
- (interactive "fPlain File: \nFEncrypted File: ")
- "Encrypt FILE to ENCRYPTED-FILE with netrc-encrypting-method cipher."
- (when (and (file-exists-p plain-file)
- (stringp encrypted-file)
- netrc-encrypting-method
- netrc-openssl-path)
- (let ((buffer-file-coding-system 'binary)
- (coding-system-for-read 'binary)
- (coding-system-for-write 'binary)
- (password
- (password-read
- (format "OpenSSL Password for cipher %s? "
- netrc-encrypting-method)
- (format "netrc-openssl-password-%s"
- netrc-encrypting-method))))
- (when password
- (with-temp-buffer
- (insert-file-contents plain-file)
- (setenv "NETRC_OPENSSL_PASSWORD" password)
- (shell-command-on-region
- (point-min)
- (point-max)
- (format "%s %s -pass env:NETRC_OPENSSL_PASSWORD -e"
- netrc-openssl-path
- netrc-encrypting-method)
- t
- t)
- (write-file encrypted-file t))))))
-