Package: pwdhash
PwdHash 1 and 2, in PythonThis is a Python implementation ofPwdHashandPwdHash2, accessible from the command line.It is function-equivalent to the originalPwdHashbrowser add-on, as well as the updated version.It does not require any dependency, and should work on any Python 3.4+.It includes many options, and should be easy to integrate into any workflow.Installationpip install pwdhashUsageOnce installed with pip,pwdhashandpwdhash2commands should be available in the PATH.pwdhash❯pwdhash-h
usage:pwdhash[-h][-s][-t][-c][-n]domain

ComputesPwdHash1

positionalarguments:domainthedomainoruriofthesite

optionalarguments:-h,--helpshowthishelpmessageandexit-s,--stdinGetpasswordfromstdininsteadofprompt.Defaultisprompt-t,--twiceAskpasswordtwice,andcheckbotharethesame.Defaultisonce-c,--copyCopyhashtoclipboardinsteadofdisplayingit.Defaultisdisplay-nDonotprintthetrailingnewlinepwdhash2❯pwdhash2-h
usage:pwdhash2[-h][-s][-t][-c][-n][--saltSALT][--iterationsITERATIONS]domain

ComputesPwdHash2

positionalarguments:domainthedomainoruriofthesite

optionalarguments:-h,--helpshowthishelpmessageandexit-s,--stdinGetpasswordfromstdininsteadofprompt.Defaultisprompt-t,--twiceAskpasswordtwice,andcheckbotharethesame.Defaultisonce-c,--copyCopyhashtoclipboardinsteadofdisplayingit.Defaultisdisplay-nDonotprintthetrailingnewline--saltSALTSalt--iterationsITERATIONSHowmanyiterationspython pwdhash.pyIf sources are available, the script can also be called withpython pwdhash.pyor./pwdhash.py.❯pythonpwdhash.py-h
usage:pwdhash.py[-h][-s][-t][-c][-n][-v{1,2}][--saltSALT][--iterationsITERATIONS]domain

ComputesPwdHash1orPwdHash2

positionalarguments:domainthedomainoruriofthesite

optionalarguments:-h,--helpshowthishelpmessageandexit-s,--stdinGetpasswordfromstdininsteadofprompt.Defaultisprompt-t,--twiceAskpasswordtwice,andcheckbotharethesame.Defaultisonce-c,--copyCopyhashtoclipboardinsteadofdisplayingit.Defaultisdisplay-nDonotprintthetrailingnewline-v{1,2},--version{1,2}UsePwdHash1or2.Defaultis1--saltSALTSalt--iterationsITERATIONSHowmanyiterationsPwdHash ExamplesDomain name is required as an argument, and password is entered in a prompt, without being displayed :❯pwdhashexample.com
Password:4kydhtBD9M--stdinIt's possible to get the password from standard input. It displays the password if entered by the user:❯pwdhash--stdinexample.com
p4ssw0rd
4kydhtBD9Mbut it allows to get the password from a pipe or a file:❯pwdhash--stdinexample.com<password
4kydhtBD9M
❯catpassword|pwdhash--stdinexample.com
4kydhtBD9M
❯echo"p4ssw0rd"|pwdhash--stdinexample.com
4kydhtBD9M--twiceIt's possible to ask for the password twice, in order to avoid typos:❯ pwdhash --twice example.com
Password:
Enter password again:
ERROR: Passwords did not match.pwdhashreturns as usual if both passwords match:❯ pwdhash --twice example.com
Password:
Enter password again:
4kydhtBD9M--copyIt's possible to copy the password directly to the clipboard. It requires thepyperclipmodule. The password isn't displayed at all.❯pwdhash--stdin--copyexample.com<password-nPasswords can also be displayed without trailing newline:❯pwdhash--stdinexample.com-n<password
4kydhtBD9M%PwdHash2 Examples❯pwdhash2example.com
Exception:Pleasedefine'PWDHASH2_SALT'environmentvariable,orspecify--salt.PwdHash2 requires a Salt:❯pwdhash2example.com--saltChangeMe
Exception:Pleasedefine'PWDHASH2_ITERATIONS'environmentvariable,orspecify--iterations.and a number of iterations:❯pwdhash2example.com--saltChangeMe--iterations50000Password:
7qErBOIB6R
❯pwdhash2example.com--saltChangeMe--iterations50000--stdin<password
7qErBOIB6REnvironment variablesSalt and Iterations can also be specified asenvironment variables:❯PWDHASH2_SALT=ChangeMePWDHASH2_ITERATIONS=50000pwdhash2example.com--stdin<password
7qErBOIB6RIf you define those variables inside your.bashrcor.zshrc, you don't need to specify them anymore:❯pwdhash2example.com--stdin<password
7qErBOIB6RCall from Python scriptimportpwdhashprint(pwdhash.extract_domain('https://subdomain.example.com/folder'))# example.comprint(pwdhash.pwdhash('example.com','p4ssw0rd'))# 4kydhtBD9Mprint(pwdhash.pwdhash2('example.com','p4ssw0rd',50_000,'ChangeMe'))# 7qErBOIB6RTests❯pytest-v=================================testsessionstarts==================================collected15items

test_pwdhash.py::TestPwdHash::test_empty_pwdhashPASSED[6%]test_pwdhash.py::TestPwdHash::test_pwdhash1_with_domainsPASSED[13%]test_pwdhash.py::TestPwdHash::test_pwdhash1_with_urlsPASSED[20%]test_pwdhash.py::TestPwdHash::test_pwdhash1_with_utf8PASSED[26%]test_pwdhash.py::TestPwdHash2::test_pwdhash2_collisionsPASSED[33%]test_pwdhash.py::TestPwdHash2::test_pwdhash2_edge_casesPASSED[40%]test_pwdhash.py::TestPwdHash2::test_pwdhash2_with_urlsPASSED[46%]test_pwdhash.py::TestPwdHashCLI::test_cli_pwdhashPASSED[53%]test_pwdhash.py::TestPwdHashCLI::test_cli_pwdhash2PASSED[60%]test_pwdhash.py::TestPwdHashCLI::test_cli_pwdhash_to_clipboardPASSED[66%]test_pwdhash.py::TestPwdHashCLI::test_pwdhash_v1_scriptPASSED[73%]test_pwdhash.py::TestPwdHashCLI::test_pwdhash_v2_scriptPASSED[80%]test_pwdhash.py::TestInteractivePwdHash::test_input_passwordPASSED[86%]test_pwdhash.py::TestInteractivePwdHash::test_input_password_no_newlinePASSED[93%]test_pwdhash.py::TestInteractivePwdHash::test_input_password_v2PASSED[100%]==================================9passedin0.46s===================================AuthorsBased onStanford PwdHashJoost Rijneveld, 2015Eric Duminil, 2022