我遇到了以下代码来解码密码字符串,例如,我的密码字符串是“samplepassword”,我可以使用base64算法对其进行编码,得到下面的编码值。我刚用过https://io/Utils/Base64/ 查找编码值。 “c2FtcGxlcGFzc3dvcmQ=”
下面的代码隐藏了我的确切密码,即“samplepassword”,但任何使用encodedvalue的人都可以使用相同的密码轻松找到原始密码https://io/Utils/Base64/.
我不明白base64模块提供了什么样的安全性,请建议一些在python代码中隐藏密码的最佳实践
def decode(encoded_value):
try:
import base64
try:
decoded_value = base64.b64decode(encoded_value).decode('ascii')
return decoded_value
except TypeError as e:
raise TypeError("Attempted to decode {value} once. Illegal Value. ".format(value=encoded_value))
except ImportError:
raise ImportError("Base64 import failed")
print(decode('c2FtcGxlcGFzc3dvcmQ='))
目前没有回答
相关问题 更多 >
编程相关推荐