pythongeneratorhoneypot

I want to print the unique password and 19 random passwords from the txt file. How can I make this work?


from random import shuffle 
print('give me your password') 
password = input()
def generator():
    g = open('Desktop/COWRIE/passwords.txt', "r")
    passwords = g.read().split("\n")
    shuffle(passwords)
    g.close()
    txt = print ('YOUR HONEYPOT IS :','\n')
    for i in range(1,20):
        passwords[i]
        print(passwords[i])
        
        
if __name__ == "__main__":
    generator()

Solution

  • Did you mean that you wanted to mix the user entered password with another 19 from a file?

    from random import shuffle 
    
    def generator():
        password = input('give me your password: ')
        with open('Desktop/COWRIE/passwords.txt', "r") as g:
            passwords = g.read().split("\n")
    
        shuffle(passwords)
        passwords = passwords[:19]
        passwords.append(password)
        shuffle(passwords)
    
        print ('YOUR HONEYPOT IS :\n')
        for pw in passwords:
            print(pw)
            
    if __name__ == "__main__":
        generator()