Remember and copy passwords to clipboard using Pyperclip module in Python
It is always a difficult job to remember all our passwords for different accounts. So this is a really simple Python program which uses
sys module to obtain account name as argument form the command terminal and
pyperclip module to paste the respective account’s password to the clipboard.
Pyperclip module does not come pre-installed with Python. To install it type the below command in the terminal.
pip install pyperclip
Command terminal Input : name_of_program.py facebook
Command terminal Output : Password : shubham456, for facebook account has been copied to the clipboard
Command terminal Input : name_of_program.py Ayushi
Command terminal Output : No such account record exists
Approach : We initialize a dictionary with keys as account names and passwords as their values. Here
sys.argv is the list of command-line arguments passed to the Python program,
sys.argv is the name of the Python program and
sys.argv corresponds to the first argument written by the user.
Then the program checks whether such an account (key) exists in the dictionary or not if such an account exists then it copies the password to the clipboard and displays a corresponding message. If no such account exists then the program displays a message that “No such account record exits”.
Below is the implementation of above approach :