There are two functions in python which can convert the ascii to the integer equivalent and vice versa.
To convert ascii character to integer representation use ord()
, to convert integer to ascii representation use chr()
.
Example:
plaintext = "hello world!" ascii_to_num = [ord(pt) for pt in plaintext] print(ascii_to_num) num_to_ascii = ''.join(chr(an) for an in ascii_to_num) print(num_to_ascii)
Result
[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]
hello world!