# How does the tor hash-password option work?

I'm trying to write a little python GUI to make interaction with tor control easier on windows, to make using hidden services easier. I'd like to be able to use a password to authenticate, but tor.exe --hash-password mypassword didn't print out anything, and I'd like to be able to hash the password in python anyway.

I looked in main.c and found the function do_hash_password but I don't know which included file to look at to see how all the other functions are used.

## 3 Answers

First off, if --hash-password doesn't work please file a bug on the bug tracker.

You can check out Stem's integration tests to see how to calculate a password hash using Python.

• --hash-password Does work, but output isn't working. I discovered this by doiing subprocess.check_output(['tor.exe', '--hash-password', 'stuff']) in python. This seems to be a known problem, or at least very similar to an old one I saw mention of online. Thanks for the link to the python stuff! It still doesn't totally explain it though, since it doesn't explain how how is chosen. I can probably figure it out. – Broseph Mar 17 '15 at 3:17

If you're using Windows PowerShell then try this

tor --hash-password YourPasswordhere | out-file -filepath \path\to\somewhere\filename.txt


https://gitweb.torproject.org/torspec.git/tree/control-spec.txt#n3007

If the 'HashedControlPassword' option is set, it must contain the salted
hash of a secret password.  The salted hash is computed according to the
S2K algorithm in RFC 2440 (OpenPGP), and prefixed with the s2k specifier.
This is then encoded in hexadecimal, prefixed by the indicator sequence
"16:".