         (aes-decrypt-buffer-or-string (current-buffer))
         (set-buffer-modified-p mod-flag)
         (add-hook 'write-file-functions
-                  'aes-encrypt-current-buffer-check nil t)))
+                  'aes--encrypt-current-buffer-check nil t)
+        ))
   (goto-char (point-min))
   (point-max))
 

;; For customizing this library, there is the customization group aes
;; in the applications group.

;; Version 24.4 is recommended
;; Version 24.3 should only be used, if the patch described in [11]
;; is applied, because there is a bug that causes passwords to be
;; shown in the minibuffer.
;; Versions 24.1 and 24.2 were not tested.
;; Versions 22 to 23 are recommended.
;; Version 21 and below are no longer supported.

;; This implementation allows additionally to the AES specification
;; blocklengths of 24 and 32 bytes.

    (goto-char (point-min))
    (looking-at "aes-encrypted V [0-9]+.[0-9]+-.+\n")))

(defvar aes--save-temp-buffer nil
  "Temporary storage variable for buffer content.")

(defun aes--encrypt-current-buffer-check ()
  "Encrypt current buffer, if it is not encrypted.
Return nil."
  (if (not (aes-is-encrypted))
      (progn
        (setq aes--save-temp-buffer (point))
        (aes-encrypt-buffer-or-string (current-buffer))
        (add-hook 'after-save-hook
                  'aes--restore-buffer-from-temp-var)
        nil)))

(defun aes--restore-buffer-from-temp-var ()
  "Restore Buffer content from temp variable."
  (remove-hook 'after-save-hook
               'aes--restore-buffer-from-temp-var)
  (aes-decrypt-current-buffer)
  (goto-char aes--save-temp-buffer)
  (setq aes--save-temp-buffer nil)
;  (erase-buffer)
;  (insert aes--save-temp-buffer)
;  (setq buffer-file-coding-system
;        (car (find-coding-systems-region
;              (point-min) (point-max))))
  (set-buffer-modified-p nil)
;  (setq aes--save-temp-buffer nil)
  )

(defun aes-encrypt-current-buffer (&optional password)
  "Encrypt current buffer.
