Loading... # base64_to_hex ``` def base64_to_hex(payload_base64): bytes_out = base64.b64decode(payload_base64) str_out = bytes_out.hex() print("base64_to_hex:",str_out) return str_out ``` # hex_to_base64 ``` def hex_to_base64(payload_hex2): bytes_out = bytes.fromhex(payload_hex2) str_out = base64.b64encode(bytes_out) print("hex_to_base64:",str_out) return str_out ``` # strToBase64 ``` def strToBase64(s): ''' 将字符串转换为base64字符串 :param s: :return: ''' strEncode = base64.b64encode(s.encode('utf8')) return str(strEncode, encoding='utf8') ``` # base64ToStr ``` def base64ToStr(s): ''' 将base64字符串转换为字符串 :param s: :return: ''' strDecode = base64.b64decode(bytes(s, encoding='gbk')) return str(strDecode, encoding='gbk') ``` 最后修改:2025 年 01 月 04 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏