[英]Convert base64 encoded google service account key to JSON file using Python
[英]Need a Python code to convert a secret key to base64 encoded
我生成了一個密鑰 - A0[Bt"V59.xA-bKO|/A""/Z.!#Y:wfpR ,需要將其轉換為 base64 編碼格式,請幫助使用 python 代碼來執行此操作。
對於 base64 編碼,請使用base64
模塊及其函數b64encode
。
例子 -
>>> import base64
>>> base64.b64encode("Hello")
'SGVsbG8='
>>> s = 'A0[Bt\"V59.xA-bKO|/A\"\"/Z.!#Y:wfpR'
>>> base64.b64encode(s)
'QTBbQnQiVjU5LnhBLWJLT3wvQSIiL1ouISNZOndmcFI='
對於解碼,使用b64decode()
函數 -
>>> import base64
>>> base64.b64decode('SGVsbG8=')
'Hello'
>>> base64.b64decode('QTBbQnQiVjU5LnhBLWJLT3wvQSIiL1ouISNZOndmcFI=')
'A0[Bt"V59.xA-bKO|/A""/Z.!#Y:wfpR'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.