Generate a deterministic password using a file and a password key.
Enter file name: Example.png
Enter a password key: test
Confirm password key: test
Generated Password: *?Bx0Ep1ZOO5QDC2RVAX
Press enter to copy and close...
- Install the requirements below.
- Run the script.
- Enter the name of a file in the same folder as the script (eg.
Example.png). - Enter a password key. Your input will be hidden while typing.
- Verify the password by entering it again, or skip this step by pressing enter.
- You will now see the generated password. Press enter to copy it to your clipboard and close the program.
- Python 3.9+
cryptographypackage (pip install -r requirements.txt)
On Linux, clipboard copying also needs wl-copy, xclip, or xsel.
This Python script generates a password using a file and a password key. The same file contents and key always give the same result, while changing either gives a different one. The result is not reversible: it cannot be used to retrieve the original file or key. Use a unique, strong key, since a weak key can be guessed by someone who has the source file.
- File Selection: When running the program, you will be prompted to enter the name of a file. The file must be in the same folder as the script, and you need to include the name and extension of the file (eg.
Example.png). Any file type should work. - Password Key: After selecting a valid file, you will be prompted to enter a password key. You can enter any text here (eg.
MyPassword123). It is important that you remember the key, as it will be used to (re)generate the password deterministically. - Password Confirmation: You will be asked to confirm your password key. You can re-enter it or just press enter to skip the confirmation step. It is recommended to retype the password when creating it for the first time.
- Password Generation: The file is hashed with SHA-256 and used as the salt for PBKDF2-HMAC-SHA256. The password key is then used to deterministically derive the generated password. The characters are selected and shuffled, so the same file and password key always produce the same 20-character password unless
-Lor--lengthis specified. - Copying the Password: Once the password is generated, you can either manually copy it or press enter to automatically copy it to your clipboard and close the script. If you start the program with
-Hor--hidden, the displayed password will be masked while the real password is still copied to the clipboard. - Reusing the Password: The output password you get from the program will always be the same if your file data and password key are EXACTLY the same, any tiny change to the password key or file content (metadata excluded) will give you a completely different output.
You are free to use the project however you want, I don't care. Credit would be appreciated if you use it for something tho.