G
G
genek_orlov2018-12-04 23:12:46
Python
genek_orlov, 2018-12-04 23:12:46

Convert string to bytes python?

There is initial data, namely a string of type bytes 5c06de96aaa8b921596269.pngAfter that, I convert it to type string 5c06df5ec63bc735769624.png, and after I converted it to type string, I need to return it to bytes again, but in the end result I get 5c06deff649ad920925176.png. How to translate so that there are not two slashes, but one?

import rsa
(pubkey, privkey) = rsa.newkeys(512)
print(privkey)
privkey_str = str(privkey)
key_str = str(pubkey)
key_a = key_str[10:164]
message = input("Message: ")
print(type(message))
print(message)
message = str(message).encode('utf-8')
print(type(message))
# шифруем
key = int(key_a)
crypto = rsa.encrypt(message, rsa.PublicKey(key, 65537)) #n e
print(crypto)
crypto = str(crypto)
crypto = crypto[2:-1].encode('utf-8').decode('unicode-escape')
print("this " + crypto)
print(type(crypto))
crypto = crypto.encode('unicode-escape')
print(crypto)
print(type(crypto))
print("Вывод")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question