The "bin" function gives the binary representation of a number as a string. Mse this representation as string is useful only to show the "0" and "1" on the screen, to be seen by people. Internally, the algorithms that work with the letters, be it encryption, or others, have to use the numbers - a number does not have a "base" it is a quantity - the representation of it as text will happen naturally in decimal, and the number representation for algorithms that manipulate bit by bit numbers is already in binary.
What you need, yes, is to convert your text to an encoding in Bytes. If you only use "Ord", you have Codepoint Unicode representing your character, but that number - Codepoint- does not have a fixed width, and then most cryptographic algorithms will not work (you can take each Codepoint as a 32 bit width, the equivalent of using utf-32, but it will take up space).
In short, if you want to work with text with a sequence of numbers, it is best to transform it into an object of type "bytes", using a suitable encoding (for example, "utf-8", which covers all known characters). An object "bytes" if you access each element, already gives you the number, and not an object bytes of length "1":
In [138]: for x in "maçã".encode("utf-8"):
...: print(x, end=", ")
...:
109, 97, 195, 167, 195, 163,
Already, going back to the original question, if you want, for the purpose of visualisation, see the binary representation of the numbers, just use the function "bin":
In [140]: for x in "maçã".encode("utf-8"):
...: print(x, bin(x), sep="\t")
...:
109 0b1101101
97 0b1100001
195 0b11000011
167 0b10100111
195 0b11000011
163 0b10100011
It’s not just doing
bin(84)
?– Woss
I do not know how to answer you friend, so I asked, but researching your tip.. worked very well. Thank you!
– LeoMouraIOT
@Woss puts his suggestion as an answer so he can choose the correct answer and close the question. Or else Leomouraiot put what he did to resolve and mark as correct answer to close the question.
– Leticia Rosa