Guest User

Untitled

a guest
Oct 19th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/usr/local/bin/python
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # Copyright (c) 2010, Mikhail Babich <bma@bma.su>
  5. # All rights reserved.
  6. #
  7.  
  8. from crypt import crypt
  9. from sys import exit, argv
  10. from os import urandom
  11. from random import seed, choice
  12. from getpass import getpass
  13.  
  14. SALT_ARRAY = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO" \
  15. "PQRSTUVWXYZ1234567890-=][';/.,<>?:{}+_)(*&^%$#@!`~"
  16.  
  17. def init():
  18. seed(urandom(13))
  19.  
  20.  
  21. def make_crypt(word):
  22. return crypt(word, choice(SALT_ARRAY) + choice(SALT_ARRAY))
  23.  
  24.  
  25. def main():
  26. init()
  27. try:
  28. username = raw_input("Username: ")
  29. except:
  30. return 1
  31.  
  32. try:
  33. p1 = getpass("Password: ")
  34. p2 = getpass("Again: ")
  35. except:
  36. return 1
  37.  
  38. if p1 != p2:
  39. print("Password not match")
  40. return 1
  41.  
  42. print "{user}:{crypt}".format(user=username, crypt=make_crypt(p1))
  43. return 0
  44.  
  45.  
  46. if __name__ == '__main__':
  47. exit(main())
Add Comment
Please, Sign In to add comment