M
M
Microp2016-04-27 12:13:00
Python
Microp, 2016-04-27 12:13:00

Choosing python encoding and converting bit sequence to string?

The task of encryption / decryption of text
source code asdasdasdf
binary representation 01100001011100110110010001100001011100110110010001100001011100110110010001100110
ciphertext
11011100000101000001010110111010110000010000010101001111010100010011011011111101
representation in bytes
0xdc1415bac1054f5136fd
issue, both from the ciphertext to obtain the plain text (or some gibberish), so it can be lead back to the form of presentation, in bytes?
something like an encoding in which all 256 numbers were responsible for their character or how to display invalid characters

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sly_tom_cat ., 2016-04-27
@Microp

To represent binary data in text form, BASE64 was invented ( https://ru.wikipedia.org/wiki/Base64)
In Python, BASE64 conversions are supported through the base64 library ( https://docs.python.org/3.4/library/base64. html for Python 3.4 or choose the version of python you are using)

A
Alexander, 2016-04-27
@NeiroNx

The representation is more like a hash. And in python, the string class has functions. u"blabla".decode("UTF-8").encode("CP866")
They work according to standard code tables, if you have some kind of non-standard encoding, you will have to write the table with pens, and maybe the functions themselves. If it's a hash, it won't decode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question