(self,filename,masterkey="")
return
Write out DB to given filename with optional master key.
        If no master key is given, the one used to create this DB is used.
        Resets IVs and master seeds.
Write out DB to given filename with optional master key.
        If no master key is given, the one used to create this DB is used.
        Resets IVs and master seeds.
Write out DB to given filename with optional master key . If no master key is given the one used to create this DB is used . Resets IVs and master seeds .
def write(self,filename,masterkey=""):
        '''' 
        Write out DB to given filename with optional master key.
        If no master key is given, the one used to create this DB is used.
        Resets IVs and master seeds.
        '''
        import hashlib

        header = copy(self.header)
        header.ngroups = len(self.groups)
        header.nentries = len(self.entries)
        header.reset_random_fields()

        payload = self.encode_payload()
        header.contents_hash = hashlib.sha256(payload).digest()

        finalkey = self.final_key(masterkey = masterkey or self.masterkey,
                                  masterseed = header.master_seed,
                                  masterseed2 = header.master_seed2,
                                  rounds = header.key_enc_rounds)

        payload = self.encrypt_payload(payload, finalkey, 
                                       header.encryption_type(),
                                       header.encryption_iv)

        fp = open(filename,'w')
        fp.write(header.encode())
        fp.write(payload)
        fp.close()
        return
def write ( self , filename , masterkey = "" ) : import hashlib header = copy ( self . header ) header . ngroups = len ( self . groups ) header . nentries = len ( self . entries ) header . reset_random_fields ( ) payload = self . encode_payload ( ) header . contents_hash = hashlib . sha256 ( payload ) . digest ( ) finalkey = self . final_key ( masterkey = masterkey or self . masterkey , masterseed = header . master_seed , masterseed2 = header . master_seed2 , rounds = header . key_enc_rounds ) payload = self . encrypt_payload ( payload , finalkey , header . encryption_type ( ) , header . encryption_iv ) fp = open ( filename , 'w' ) fp . write ( header . encode ( ) ) fp . write ( payload ) fp . close ( ) return