 pickle data and insert it as a header.</p>
<pre><code class="python">import hashlib
import hmac
import pickle

data = pickle.dumps(obj)
digest =  hmac.new(&#39;unique-key-here&#39;, data, hashlib.blake2b).hexdigest()
with open(f) as output:
    output.write(str(digest) + &#39; &#39; + data)
</code></pre>
<p>To verify signed data, use something like this:</p>
<pre><code class="python">import hashlib
import hmac
import pickle
import secrets

digest, pickle_data = data.split(&#39; &#39;)
expected_digest = hma