refactored encrypt_library