Exemple #1
0
 def GenPass(self, params):
     wait = True
     #Generate password
     while(wait):
         generatedPassword = enc.GeneratePassword(params)
         console.out(48)
         console.SlowPrint(generatedPassword, 0.03, ">")
         console.out(49)
         inputVal = input("")
         if(inputVal.lower()=="n" or inputVal.lower()=="no"):
             wait = False
     #Give option to save password
     
     console.out(50)
     inputVal = input("")
     if(inputVal.lower()=="y" or inputVal.lower()=="yes"):
         titleSelected = False
         passTitles = File.GetPasswordTitles(self.GetFileEncryptionKey())
         while(not titleSelected):
             console.out(51) #Get user to enter a title
             inputVal = input("")
             if(inputVal.lower() == "c"):
                 return None #Quit routine
             if(passTitles == None or inputVal not in passTitles):
                 titleSelected = True            
         
         state = File.AmmendPasswordFile(inputVal, generatedPassword, self.GetFileEncryptionKey())
         if(state):
             console.PrintList([38, "Use 'EditPass' to add more information to this stored password"], 0.02)
         else:
             console.out(39)    
         
     console.out(2)
Exemple #2
0
 def ShowPasswords(self, params):
     checkItem = 0        
     searchGroup = "NULL"
     if(len(params) > 0 and not str.isdigit(params[0])):
         searchGroup = params[0]    
         checkItem = 1
         
     titleList = File.GetPasswordTitles(self.GetFileEncryptionKey(), searchGroup)   
     
     if(titleList != None and len(titleList) != 0):
         pageNumber = 1
         pages = math.ceil(len(titleList) / 10)
         #Split titlelist into groups of 10, call by page number (must be int)
         if(len(params) > checkItem and str.isdigit(params[checkItem])):                
             pageNumber = int(params[checkItem])
         if(pageNumber > pages):
             console.outs([36,2])    
         else:
             #Get (up to) 10 results from the requested page
             firstIndex = (pageNumber - 1) * 10
             lastIndex = pageNumber * 10
             if(lastIndex > len(titleList)):
                 showPass = titleList[firstIndex:]
             else:
                 showPass = titleList[firstIndex:lastIndex]
             page = "Viewing page " + str(pageNumber) + " out of " + str(pages) + "."
             displayMessage = 34
             if(searchGroup != "NULL"):
                 displayMessage = "The group '" + searchGroup + "' contains the following:"
             console.PrintList([0, displayMessage, showPass, 2, page,0,2],0.02, ">", [4])            
     else:
         if(searchGroup == "NULL"):
             console.outs([2,35,0,2])
         else:
             console.PrintList([2,"No stored passwords found in the '" + searchGroup + "' group.",0,2], 0.02)
Exemple #3
0
    def AddPass(self, params):
        #Check if password title is already taken
        userTitle = params[0]

        passTitles = File.GetPasswordTitles(self.GetFileEncryptionKey())
        if(passTitles == None or userTitle.lower() not in (name.lower() for name in passTitles)): #Prevent passwords under the same name
            #password doesn't exist, can create
            if(len(params)==3):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2])
            elif(len(params)==4):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3])
            elif(len(params)==5):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3], params[4])
            else:
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey())
            if(state):
                console.out(38)
            else:
                console.out(39)
        else:
            #password with title already exists
            console.out(40)      
        self.toClear = True