Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. # How this works:
  2. # uses random to get a random number
  3. # checks what hash method to use
  4. # uses that method to hash the random number
  5. # returns the value
  6.  
  7. import hashlib
  8. import random as rand
  9.  
  10.  
  11. def hexrandom(minint, maxint, shamode="sha1"):
  12. x = str(rand.randint(int(minint), int(maxint)))
  13. reval = None
  14. if shamode == "sha1":
  15. reval = hashlib.sha1(x.encode()).hexdigest()
  16. elif shamode == "sha224":
  17. reval = hashlib.sha224(x.encode()).hexdigest()
  18. elif shamode == "sha256":
  19. reval = hashlib.sha256(x.encode()).hexdigest()
  20. elif shamode == "sha384":
  21. reval = hashlib.sha384(x.encode()).hexdigest()
  22. elif shamode == "sha512":
  23. reval = hashlib.sha512(x.encode()).hexdigest()
  24.  
  25. return reval
Add Comment
Please, Sign In to add comment