Answer the question
In order to leave comments, you need to log in
How to encrypt data in Python 3.3?
Hello. I have the following problem - I need to encrypt strings on Paython. It's just that XOR is not very appropriate in this case, so I tried to google AES or Blowfish. But unfortunately the PyCrypto library is written in an old version of Python, blowfish too. Can anyone suggest data encryption libraries for Python 3.3?
Answer the question
In order to leave comments, you need to log in
PyCrypto supports python 3.3.
https://pypi.python.org/pypi/pycrypto
Maybe your Windows didn't build right away because of stackoverflow.com/questions/13787258/pycrypto-inst... ? But there the solution is indicated (either take an untrusted binary from the Internet, or collect it from under mingw).
If it doesn't work - then try bindings to OpenSSL (pyOpenSSL https://github.com/pyca/pyopenssl )
If it’s still relevant to help others, try simple RSA in Python
https://pypi.python.org/pypi/rsa
After downloading, let’s start encryption:
import rsa
(pubkey, privkey) = rsa.newkeys(512)
message = b'Hello Blablacode.ru!'
# шифруем
crypto = rsa.encrypt(message, pubkey)
print(crypto)
#расшифровываем
message = rsa.decrypt(crypto, privkey)
print(message)
$ python3 rsa_test.py
b'\x19\xd1\xbb\xf8N\xb7\xa8F\xf2\x19\xaa\xd1\x17\x868\xbcn\xc8\x85\xd4r\x81\xdaK\x0f\x80\xee1P\xdd\xdcV5\xed\x12\xf6S\x7f\xd7&f\x9e\xdawC\x038\xbb\xbaX\x8ae\x18\xeaR\x12E\r\x90\xc5c\x18\xd4\r'
b'Hello Blablacode.ru!'
You can try cryptography .
Links:
'Alex Gaynor -- Why Crypto' -- alexgaynor.net/2014/feb/12/why-crypto
Docs -- https://cryptography.io/en/latest/#
PyPI -- https://pypi. python.org/pypi/cryptography
Nothing worked with PyCrypto on Mac. error: no commands supplied.
Last login: Tue Feb 25 21:23:02 on ttys000
MacBook-Air-Danila:~ danilausacev$ cd '/Users/danilausacev/Downloads/pycrypto-2.6.1/' && '/usr/bin/pythonw' '/Users /danilausacev/Downloads/pycrypto-2.6.1/setup.py' && echo Exit status: $? && exit 1
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or : setup.py cmd --help
error: no commands supplied
MacBook-Air-Danila:pycrypto-2.6.1 danilausacev$ python setup.py test
running test
Traceback (most recent call last):
File "setup.py", line 456 ,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python .framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/ python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "setup.py", line 321, in run
from Crypto import SelfTest
ImportError: No module named Crypto
MacBook-Air-Danila:pycrypto -2.6.1 danilausacev$
C Cryptography is the same crap. You need Homebrew first, then Pip, then you can only install. I installed homebrew, but problems with pip. I advise you to install it through Python. Now I have 3 pythons installed on a Mac with 128 GB. Funny.
As a result, I decided to limit myself to this - habrahabr.ru/post/212235
And nothing came of it either.
If someone will tell me a working library (and preferably even 1 script) that allows you to encrypt data, I will be very grateful
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question