Created
March 9, 2015 16:02
-
-
Save mitshel/8aa63b8c2cc119949357 to your computer and use it in GitHub Desktop.
SID Generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Name: newSID.py | |
Author: Bill Anderson <[email protected]> | |
License: LGPL | |
This is a nice little means of generating a | |
"Session ID" for things like web sessions and the like. | |
It returns an ID of the format: | |
Joe_db2039967237b1b1be33222268408c1a | |
where "Joe" was the string passed to the function. | |
""" | |
import time,whrandom,md5 | |
def getNewSID(tag): | |
"""Build a new Session ID""" | |
t1 = time.time() | |
time.sleep( whrandom.random() ) | |
t2 = time.time() | |
base = md5.new( tag + str(t1 +t2) ) | |
sid = tag + '_' + base.hexdigest() | |
return sid | |
if __name__ == '__main__': | |
print getNewSID('Joe') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment