Obfuscate strings in Python

后端 未结 6 1337
伪装坚强ぢ
伪装坚强ぢ 2021-01-02 08:54

I have a password string that must be passed to a method. Everything works fine but I don\'t feel comfortable storing the password in clear text. Is there a way to obfuscate

6条回答
  •  长发绾君心
    2021-01-02 09:34

    You should avoid storing the password in clear in the first place. That's the only "true" solution.

    Now, you can encrypt the password easily with the hash module (md5 and similar modules in python 2.5 and below).

    import hashlib
    mypass = "yo"
    a = hashlib.sha256(mypass).digest()
    

提交回复
热议问题