base64

base64

参考资料
https://blog.csdn.net/m0_37422289/article/details/82753260

str1 = "this is string example....wow!!!"

# str3 转成bytes 的string
str3 = str1.encode(encoding ='utf-8',errors = 'strict')
print (str3),
print ('')

# bytes 再进行 base64 编码
str4= base64.b64encode(str3)

print (str4)
print ('')
# 再base64 decode 一下
print (str4.decode())
print ('')
# base64 解码
enstr = base64.b64decode(str4.decode())
print(enstr.decode())


###########################################################################
def my_base64(str1):
    # str1 = '"9C37197CA7C2428388C2E6E59B829B30" && region="Hk" && after="2020-09-05"'

    # str3 转成bytes 的string
    str3 = str1.encode(encoding ='utf-8',errors = 'strict')

    # bytes 再进行 base64 编码
    str4= base64.b64encode(str3)

    # print (str4.decode())
    return str4.decode()

posted @ 2022-11-20 16:53  是谁走漏了消息  阅读(60)  评论(0)    收藏  举报