python create unreadable save file

Solutions on MaxInterview for python create unreadable save file by the best coders in the world

showing results for - "python create unreadable save file"
Eleonora
12 Jun 2020
1import hmac, pickle
2
3# pickle the data
4pickled = pickle.dumps(data)
5digest =  hmac.new("some-shared-key", pickled, 
6                   digestmod=<my choice of hasher>
7                   ).hexdigest()
8
9# now save the hashed digest and the pickled data
10with open("some-file", "wb") as f:
11    # save these in some way you can distinguish them when you read them
12    print(digest, file=f)
13    print(pickled, file=f)