2016-11-20 02:16:04 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
Password hashing utility for PyLink IRC Services.
|
|
|
|
"""
|
|
|
|
|
2016-11-20 02:47:55 +01:00
|
|
|
from pylinkirc.coremods.login import pwd_context
|
2017-01-29 09:08:36 +01:00
|
|
|
import getpass
|
2016-11-20 02:16:04 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Hashes a password for use with PyLink IRC Services.')
|
2017-01-29 09:08:36 +01:00
|
|
|
parser.add_argument('password', help='specifies the password to hash', nargs='?', default='')
|
2016-11-20 02:16:04 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2017-01-23 01:16:25 +01:00
|
|
|
assert pwd_context, 'Cannot hash passwords because passlib is missing! Install it via "pip3 install passlib".'
|
2017-01-29 09:08:36 +01:00
|
|
|
|
|
|
|
password = args.password
|
|
|
|
|
|
|
|
# If no password was given, enter one on the command line
|
|
|
|
if not password:
|
|
|
|
password = getpass.getpass()
|
|
|
|
|
|
|
|
password = password.strip()
|
|
|
|
assert password, "Password cannot be empty!"
|
2019-06-07 23:25:22 +02:00
|
|
|
print(pwd_context.hash(password))
|