creating and writing to a text file in python in a folder code example

Example 1: python create unreadable save file

import hmac, pickle

# pickle the data
pickled = pickle.dumps(data)
digest =  hmac.new("some-shared-key", pickled, 
                   digestmod=<my choice of hasher>
                   ).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)

Example 2: how to access a txt file through os library in python

my_file_handle=open("folder/test.txt")
my_file_handle.read()