def editAccount(self,id,title,description,account,password,secret,tagIds): ''' update account @param title: account title @param description: account description @param account: account name/username, emailaddr, .... @param secret: secret text from user @param password: password , it will not get updated if value is None @param tagIds: a list of related tagIds ''' conn = self.getConnection() pwdDao = PwdDao(conn) pwdObj = pwdDao.getPwdById(id) masterPwd = config.getRootPwd() ePassword = util.encrypt(masterPwd, password) if password else pwdObj.pwd eSecret = util.encrypt(masterPwd,secret) if secret else "" eUsername = util.encrypt(masterPwd, account) if account else "" current = datetime.datetime.today() pwdDao.updateAccount(id, title, description, eUsername, ePassword, eSecret, current) #2 process tags pwdDao.updateAccountTags(id, tagIds) conn.commit() conn.close()
def addAccount(self,title,description,account,password,secret,tagIds): ''' add a user input account to database @param title: account title @param description: account description @param account: account name/username, emailaddr, .... @param password: password @param secret: the secret text from user @param tagIds: a list of related tagIds ''' conn = self.getConnection() pwdDao = PwdDao(conn) # encode account & password master = config.getRootPwd() ePassword = util.encrypt(master, password.decode("utf-8")) eSecret = util.encrypt(master,secret) if secret else "" eAccount = util.encrypt(master, account) if account else "" current = datetime.datetime.today() id = pwdDao.getPwdId() #insert the account pwdDao.insertAccount(id, title, description, eAccount, ePassword, eSecret, current) #add tag to the new account if there is if len(tagIds) > 0 : pwdDao.setTagsOnAccount(id, tagIds) conn.commit() conn.close()
def addAccount(self, title, description, account, password, secret, tagIds): ''' add a user input account to database @param title: account title @param description: account description @param account: account name/username, emailaddr, .... @param password: password @param secret: the secret text from user @param tagIds: a list of related tagIds ''' conn = self.getConnection() pwdDao = PwdDao(conn) # encode account & password master = config.getRootPwd() ePassword = util.encrypt(master, password.decode("utf-8")) eSecret = util.encrypt(master, secret) if secret else "" eAccount = util.encrypt(master, account) if account else "" current = datetime.datetime.today() id = pwdDao.getPwdId() #insert the account pwdDao.insertAccount(id, title, description, eAccount, ePassword, eSecret, current) #add tag to the new account if there is if len(tagIds) > 0: pwdDao.setTagsOnAccount(id, tagIds) conn.commit() conn.close()
def getPwdById(self,pwdId): conn = self.getConnection() pwdDao = PwdDao(conn) result = pwdDao.getPwdById(pwdId) result.username = util.decrypt(config.getRootPwd(), result.username) conn.close() return result
def editAccount(self, id, title, description, account, password, secret, tagIds): ''' update account @param title: account title @param description: account description @param account: account name/username, emailaddr, .... @param secret: secret text from user @param password: password , it will not get updated if value is None @param tagIds: a list of related tagIds ''' conn = self.getConnection() pwdDao = PwdDao(conn) pwdObj = pwdDao.getPwdById(id) masterPwd = config.getRootPwd() ePassword = util.encrypt(masterPwd, password) if password else pwdObj.pwd eSecret = util.encrypt(masterPwd, secret) if secret else "" eUsername = util.encrypt(masterPwd, account) if account else "" current = datetime.datetime.today() pwdDao.updateAccount(id, title, description, eUsername, ePassword, eSecret, current) #2 process tags pwdDao.updateAccountTags(id, tagIds) conn.commit() conn.close()
def getPwdById(self, pwdId): conn = self.getConnection() pwdDao = PwdDao(conn) result = pwdDao.getPwdById(pwdId) result.username = util.decrypt(config.getRootPwd(), result.username) conn.close() return result
def changeRootPwd(self, newRootPwd): oldPwd = config.getRootPwd() conn = self.getConnection() masterDao = MasterDao(conn) pwdDao = PwdDao(conn) # 1 re-encrypt all passwords with new root pwd accountList = pwdDao.getAllPasswd() currentDate = datetime.datetime.today() for account in accountList: dePassword = util.decrypt(oldPwd, account.pwd) enPassword = util.encrypt(newRootPwd, dePassword) if account.secret: deSecret = util.decrypt(oldPwd, account.secret) enSecret = util.encrypt(newRootPwd, deSecret) else: enSecret = "" deUsername = util.decrypt(oldPwd, account.username) enUsername = util.encrypt(newRootPwd, deUsername) account.pwd = enPassword account.username = enUsername account.secret = enSecret account.lastupdate = currentDate pwdDao.updateAccount(account.id, account.title, account.description, account.username, account.pwd, account.secret, account.lastupdate) # 2 get md5 of new root pwd, update the rootpassword table newMd5String = util.md5Encode(newRootPwd) masterDao.updateMasterPwd(newMd5String) # 3 update master password in config module. config.setRootPwd(newRootPwd) conn.commit() conn.close()
def changeRootPwd(self,newRootPwd): oldPwd = config.getRootPwd() conn = self.getConnection() masterDao = MasterDao(conn) pwdDao = PwdDao(conn) # 1 re-encrypt all passwords with new root pwd accountList = pwdDao.getAllPasswd() currentDate = datetime.datetime.today() for account in accountList: dePassword = util.decrypt(oldPwd, account.pwd) enPassword = util.encrypt(newRootPwd, dePassword) if account.secret: deSecret = util.decrypt(oldPwd, account.secret) enSecret = util.encrypt(newRootPwd, deSecret) else: enSecret = "" deUsername = util.decrypt(oldPwd, account.username) enUsername = util.encrypt(newRootPwd, deUsername) account.pwd = enPassword account.username = enUsername account.secret = enSecret account.lastupdate = currentDate pwdDao.updateAccount(account.id,account.title, account.description, account.username, account.pwd, account.secret,account.lastupdate) # 2 get md5 of new root pwd, update the rootpassword table newMd5String = util.md5Encode(newRootPwd) masterDao.updateMasterPwd(newMd5String) # 3 update master password in config module. config.setRootPwd(newRootPwd) conn.commit() conn.close()
def decryptUsername(self, pwd): if pwd.username: pwd.username = util.decrypt(config.getRootPwd(),pwd.username) return pwd
def decryptUsername(self, pwd): if pwd.username: pwd.username = util.decrypt(config.getRootPwd(), pwd.username) return pwd