SHARE
TWEET

жопный код

a guest Aug 24th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import choice
  2. from string import ascii_letters
  3. from hashlib import md5
  4. from secrets import token_hex as salt
  5.  
  6. salt = salt()
  7. users = {'admin':'admin'}
  8. tokens = {}
  9. def create_token(login,password):
  10.     global tokens
  11.     tokens[login] = md5((salt+login+password).encode()).hexdigest()
  12.  
  13. create_token('admin',users['admin'])
  14.  
  15. users_secrets = {tokens['admin']:'<redacted>'}
  16. access_denied = ['admin']
  17.  
  18. def registration():
  19.     login = input('New login: ')
  20.     if login not in users:
  21.         password = input('Password: ')
  22.         users[login] = password
  23.         create_token(login,password)
  24.         print('Success!')
  25.     else:
  26.         print('User already exsist.')
  27. def authed(login, password):
  28.     global tokens
  29.     global users_secrets
  30.     token = tokens[login]
  31.     print('Welcome back {0}!'.format(login))
  32.     while True:
  33.         choice_0 = input('[1] - Show secret\n[2] - New secret\n')
  34.         if choice_0 == '1':
  35.             if token in users_secrets:
  36.                 print('Your secret: {0}'.format(users_secrets[token]))
  37.             else:
  38.                 print('You have not secrets.')
  39.         elif choice_0 == '2':
  40.             secret = input('Enter your secret: ')
  41.             users_secrets[token] = secret
  42.    
  43.  
  44. print('Welcome to the SecretsStore!')
  45. while True:
  46.     print('[1] - login\n[2] - registration\n[3] - quit')
  47.     choice = input()
  48.     if choice == '1':
  49.         login = input('Login: ')
  50.         if login in users and login != 'admin':
  51.             password = input('Password: ')
  52.             if users[login] == password:
  53.                 authed(login,password)
  54.             else:
  55.                 print('Wrong password!')
  56.         else:
  57.             print('No such user.')
  58.     elif choice == '2':
  59.         registration()
  60.     elif choice == '3':
  61.         print('Bye!')
  62.         exit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top