0

i am making a program for me to use in school (on a public server) and some people are changing it and ruining my passwords that are stored in it, could someone please tell me how to convert a string to binary or hex and vice-versa so that people cant see the passwords bear in mind that the people in school are not so brilliant at coding and will be fooled by something quite simple i also dont think that i have the rights to install things on the school computers.

0

1 Answer 1

1

Besides the fact, that you should not store your passwords so accessible, the base64 module does exactly what you want.

Here an example:

from base64 import b64encode, b64decode

mypw = "mypassword".encode()     # needs to be a binary-string
encrPW = b64encode(mypw)         # equals b'bXlwYXNzd29yZA=='
assert mypw == b64decode(encrPW) # decoding results in the password
strPW = mypw.decode()            # the python-string representation of the password
                                 # (most possibly the one you need later on)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.