Easy encryption of file contents (Python)

Output text.txt to text.encode.txt.

With Python

encode.py



# coding:UTF-8

#Read stream
with open("text.txt","r") as origin_file:
  stream_raw = origin_file.read()
  # ord()Get code value with
  str_code_num = (ord(str) for str in stream_raw)
  #Code value from 0 to 255
  seed = 255
  #Connect while xor
  enc_result = "".join(map(lambda str: chr(str^seed), str_code_num))
  
#Export to file
with open('text.encode.txt', 'w') as new_file:
  new_file.write(enc_result)
  

Recommended Posts

Easy encryption of file contents (Python)
Summary of python file operations
Template of python script to read the contents of the file
[Python] [Table of Contents Links] Python Programming
Python Math Series ⓪ Table of Contents
Introductory table of contents for python3
Check the existence of the file with python
Easy introduction of speech recognition with Python
[Python] Get the character code of the file
Easy introduction of python3 series and OpenCV3
[Python3] Understand the basics of file operations
Script python file
Introduction of Python
Python is easy
Python file processing
Basics of Python ①
Basics of python ①
Copy of python
Contents of __name__
Introduction of Python
The contents of the Python tutorial (Chapter 5) are itemized.
The contents of the Python tutorial (Chapter 4) are itemized.
The contents of the Python tutorial (Chapter 2) are itemized.
The contents of the Python tutorial (Chapter 8) are itemized.
The contents of the Python tutorial (Chapter 1) are itemized.
[Python] [chardet] Automatic detection of character code of file
The contents of the Python tutorial (Chapter 10) are itemized.
Easy understanding of Python for & arrays (for super beginners)
Automating simple tasks with Python Table of contents
[Python] Summary of S3 file operations with boto3
The contents of the Python tutorial (Chapter 6) are itemized.
Convert the character code of the file with Python3
The contents of the Python tutorial (Chapter 3) are itemized.
Speed evaluation of CSV file output in Python
Get the update date of the Python memo file.
[Python] Operation of enumerate
List of python modules
Easy way to check the source of Python modules
File operations in Python
[Python] File / directory operations
Python 2> Implementation> {Erase leading whitespace | Add Markdown header (###)} | Example of sed erasing file contents
Unification of Python environment
Copy of python preferences
Make a copy of a Google Drive file from Python
[Python] Get the official file path of the shortcut file (.lnk)
Obtained contents of sosreport
Basics of Python scraping basics
[python] behavior of argmax
Automatically execute python file
Easy partial download of mp4 with python and youtube-dl!
Usage of Python locals ()
the zen of Python
Reading pyc file (Python 3.5.2)
Installation of Python 3.3 rc1
File operations in Python
Not being aware of the contents of the data in python
[Note] Contents of shape [0], shape [1], shape [2]
# 4 [python] Basics of functions
Creating BINGO "Web Tools" with Python (Table of Contents)
Basic knowledge of Python
[Maya Python] Crush the contents of the script 2 ~ list Notes