D
D
deleted-dazgalbag2015-07-02 18:58:49
Python
deleted-dazgalbag, 2015-07-02 18:58:49

How to encrypt a string using Python?

Hello.
I need to encrypt some number using both Python and PyCrypto library. Wrote the following test script:

import hashlib
from Crypto.Cipher import AES

password = "catch"
key = hashlib.sha256(password).digest()
iv = 16 * '\x00'
mode = AES.MODE_CBC
some = 38
encryptor = AES.new(key, mode, iv)
print(some)
some = encryptor.encrypt(str(some) * 16)
print(some)

But when I run it, the output is:
38
ۼ5b v{/|[email protected]`l
The first line is fine for me, but the second is unexpected.
Screenshot attached:
8a9c181de8964b378d40cf2b088cfdfa.png
Question: how to deal with this? Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-07-02
@deleted-dazgalbag

So

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question