📜  python 创建不可读的保存文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:58.880000             🧑  作者: Mango

代码示例1
import hmac, pickle

# pickle the data
pickled = pickle.dumps(data)
digest =  hmac.new("some-shared-key", pickled, 
                   digestmod=
                   ).hexdigest()

# now save the hashed digest and the pickled data
with open("some-file", "wb") as f:
    # save these in some way you can distinguish them when you read them
    print(digest, file=f)
    print(pickled, file=f)