def change_password (new_pass, old_pass): enc_novo = Encriptador (new_pass) enc_velho = Encriptador (old_pass) # testa se a senha informada esta correta f = open (CHECK_FILE, 'r') check = f.read() f.close() if enc_velho.decripta ( check ) != CHECK_STR: return False # se nao tiver cai fora cols = Collection.select() for c in cols: nome = enc_velho.decripta (c.nome) c.nome = enc_novo.encripta (nome) print "migrando colection ", nome c.save() sens = Senha.select() for s in sens: desc = enc_velho.decripta (s.desc) valor = enc_velho.decripta (s.valor) s.desc = enc_novo.encripta (desc) s.valor = enc_novo.encripta (valor) print "migrando senha ", desc s.save() f = open (CHECK_FILE, 'w') f.write ( enc_novo.encripta (CHECK_STR) ) f.close()
def salvar (self): s = Senha() s.collect = self.collect s.desc = self.smanager.encrypter.encripta (self.ids.tx_desc.text) s.valor = self.smanager.encrypter.encripta (self.ids.tx_password.text) s.save() # Vai pra view from telas.passwd import JanelaPassView janela = JanelaPassView(smanager=self.smanager, name='janela_pass_view') self.smanager.add_widget( janela ) #janela = self.smanager.get_screen('janela_pass_view') janela.setup (passwd=s) self.smanager.transition.direction = 'right' self.smanager.current = 'janela_pass_view'
def migra (e): from models.senhas import Senha, Collection cols = Collection.select() for c in cols: nome = e.decripta (c.nome) c.nome = e.encripta (nome) print "migrando colection ", nome c.save() sens = Senha.select() for s in sens: desc = e.decripta (s.desc) valor = e.decripta (s.valor) s.desc = e.encripta (desc) s.valor = e.encripta (valor) print "migrando senha ", desc s.save() f = open (CHECK_FILE, 'w') f.write ( e.encripta (CHECK_STR) ) f.close()
def recarrega (self): self.ids.area_pass.clear_widgets() sens = Senha.select().where( Senha.collect==self.collection ) for s in sens: b = ItemPass (passwd=s, smanager=self.smanager) self.ids.area_pass.add_widget(b)