Answer the question
In order to leave comments, you need to log in
Convert string to bytes python?
There is initial data, namely a string of type bytes After that, I convert it to type string , and after I converted it to type string, I need to return it to bytes again, but in the end result I get . 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 questionAsk a Question
731 491 924 answers to any question