Created
July 29, 2016 19:35
-
-
Save s4w3d0ff/817f3a1c24738d29b7775f9386d3719a to your computer and use it in GitHub Desktop.
Launches subprocess 'tor --hash-password' and returns the hashed password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen, PIPE | |
import logging | |
def genTorPassHash(password): | |
""" Launches a subprocess of tor to generate a hashed <password>""" | |
logging.info("Generating a hashed password") | |
torP = Popen(['tor', '--hush', '--hash-password', str(password)], stdout=PIPE, bufsize=1) | |
try: | |
with torP.stdout: | |
for line in iter(torP.stdout.readline, b''): | |
line = line.strip('\n') | |
if not "16:" in line: | |
logging.debug(line) | |
else: | |
passhash = line | |
torP.wait() | |
logging.info("Got hashed password") | |
return passhash | |
except Exception as e: | |
logging.exception(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment