Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # How this works:
- # uses random to get a random number
- # checks what hash method to use
- # uses that method to hash the random number
- # returns the value
- import hashlib
- import random as rand
- def hexrandom(minint, maxint, shamode="sha1"):
- x = str(rand.randint(int(minint), int(maxint)))
- reval = None
- if shamode == "sha1":
- reval = hashlib.sha1(x.encode()).hexdigest()
- elif shamode == "sha224":
- reval = hashlib.sha224(x.encode()).hexdigest()
- elif shamode == "sha256":
- reval = hashlib.sha256(x.encode()).hexdigest()
- elif shamode == "sha384":
- reval = hashlib.sha384(x.encode()).hexdigest()
- elif shamode == "sha512":
- reval = hashlib.sha512(x.encode()).hexdigest()
- return reval
Add Comment
Please, Sign In to add comment