Python Base64 解密脚本 - 代码示例与解释
以下是一个使用 Python 编写的 Base64 解密脚本示例:
import base64
def base64_decode(data):
'解密 Base64 编码的数据'
try:
decoded = base64.b64decode(data)
return decoded.decode('utf-8')
except:
return '解密失败'
# 示例数据
encoded_data = 'dGVzdGluZyBzdHJpbmcgY29udGVudA=='
# 解密数据
decoded_data = base64_decode(encoded_data)
# 输出解密结果
print(decoded_data)
在这个脚本中,我们使用 Python 中的 base64 模块来解密 Base64 编码的数据。base64_decode 函数接受一个 Base64 编码的字符串作为输入,并返回解密后的字符串。如果解密失败,则返回一个错误消息。
在示例中,我们使用字符串 dGVzdGluZyBzdHJpbmcgY29udGVudA== 作为输入数据进行解密。解密后的结果是 testing string content。
原文地址: https://www.cveoy.top/t/topic/l2Yh 著作权归作者所有。请勿转载和采集!