def write_store(self,store):
"""
Commit store to file.
"""
inner_data = json.dumps(store).encode('utf-8')
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
enc_bytes = self._box.encrypt(inner_data,nonce)
enc_blob = bytes_to_hex_str(enc_bytes)
outer_data = {
'hash': self._hash,
'salt': bytes_to_hex_str(self._salt),
'iterations': self._iterations,
'enc_blob': enc_blob,
}
with open(self._path,'w',encoding='ascii') as fw:
json.dump(outer_data,fw)
评论列表
文章目录