python - python中密码字符串的Base64编码
问题描述
我遇到了以下代码来解码密码字符串,例如我的密码字符串是“samplepassword”,我可以使用 base64 算法对其进行编码,并得到以下编码值。我只是使用 https://io/Utils/Base64/ 来查找编码值。"c2FtcGxlcGFzc3dvcmQ="
下面的代码隐藏了我的确切密码“samplepassword”,但任何使用编码值的人都可以使用相同的 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='))
解决方案
推荐阅读
- keras - 使用 Keras ImageDataGenerator 增强边界框
- ruby-on-rails - Graphhopper - 覆盖权重类并将其集成到 Ruby on Rails
- cucumber-jvm - 如果一个场景失败,继续黄瓜特征文件中的下一个场景
- java - Spring 集成中的成功通道是动态的
- c# - 检索数据网格上的特定行
- php - 如何显示用户的最后记录
- android - 试图从类 androidx.room.CoroutinesRoom$Companion 访问类 kotlin.jvm.internal.DefaultConstructorMarker
- c# - 自动更新 Azure 身份验证的最佳方法是什么?
- c# - 异步/等待在方法结束时抛出异常
- webpack - Webpack 将一些文本注入站点