Refactored encrypt file contents