Decrypt files encrypted with openssl from python with openssl

I used to write an article about encrypting and decrypting using the python library, but I realized that in most cases it is enough to run openssl from a command without doing that. : sweat_smile:

Operation check environment arch linux openssl 1.1.1 python3.8.1

$ openssl enc -e -aes-256-cbc -k 'password' -in original_file -out encrypted_file

With openssl 1.1.1, you will get a warning "Using -iter or -pbkdf2 would be better.", But be aware that with this option you will not be able to decrypt with older versions.

decrypt.py


from subprocess import run, PIPE
password = 'password'
file_path = 'encrypted_file'

completed = run(args=[
    'openssl', 'enc', '-d', '-aes-256-cbc',
    '-k', password, '-in', file_path],
    check=True, stdout=PIPE)
print(completed.stdout.decode())

Recommended Posts

Decrypt files encrypted with openssl from python with openssl
Decrypt files encrypted with openssl from python with openssl
Play audio files from Python with interrupts
Decrypt a string encrypted on iOS with Python
Manipulate excel files from python with xlrd (personal notes)
Sorting image files with Python (2)
Sort huge files with python
Sorting image files with Python (3)
Sorting image files with Python
Integrate PDF files with Python
Reading .txt files with Python
With skype, notify with skype from python!
Remove headings from multiple format CSV files with python
Call C from Python with DragonFFI
Recursively unzip zip files with python
Manipulating EAGLE .brd files with Python
Install Python from source with Ansible
[Python] POST wav files with requests [POST]
Run Aprili from Python with Orange
Handle Excel CSV files with Python
Read files in parallel with Python
Call python from nim with Nimpy
Read fbx from python with cinema4d
Extract strings from files in Python
Collecting information from Twitter with Python (Twitter API)
[AWS] Using ini files with Lambda [Python]
Receive textual data from mysql with python
Get html from element with Python selenium
[Note] Get data from PostgreSQL with Python
Create wordcloud from your tweet with python3
Business efficiency starting from scratch with Python
Create and decrypt Caesar cipher with python
Working with Azure CosmosDB from Python Part.2
Image acquisition from camera with Python + OpenCV
Reading and writing JSON files with Python
Download files on the web with Python
[Easy Python] Reading Excel files with openpyxl
Getting started with Dynamo from Python boto
Try calling Python from Ruby with thrift
Scraping from an authenticated site with python
Encrypt with Ruby (Rails) and decrypt with Python
Convert HEIC files to PNG files with Python
[Easy Python] Reading Excel files with pandas
Use C ++ functions from python with pybind11
FizzBuzz with Python3
Csv output from Google search with [Python]! 【Easy】
Scraping with Python
[Python] Get the files in a folder with Python
Extract text from PowerPoint with Python! (Compatible with tables)
Statistics with python
Scraping with Python
Study from Python Reading and writing Hour9 files
Image processing from scratch with python (5) Fourier transform
Twilio with Python
Integrate with Python
Wrap C with Cython for use from Python
Play with 2016-Python
sql from python
AES256 with python
~ Tips for Python beginners from Pythonista with love ① ~
Tested with Python