Created
April 3, 2018 09:25
-
-
Save BbsonLin/3a76d3fef751d49a03a80643d20a7d1e to your computer and use it in GitHub Desktop.
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
import time | |
import hashlib | |
serial = 'QQ0001' | |
if __name__ == '__main__': | |
now_time = time.time() | |
print(now_time) | |
h1 = hashlib.sha1() | |
h1.update((str(now_time) + serial).encode('utf-8')) | |
print('h1 is ', h1.hexdigest()) | |
h2 = hashlib.sha1() | |
h2.update((str(now_time) + serial).encode('utf-8')) | |
print('h2 is ', h2.hexdigest()) | |
print('h1 == h2 ?', (h1.hexdigest() == h2.hexdigest())) | |
# $ python h.py 2.3.5 | |
# 1522747460.2899463 | |
# h1 is 6c5fda997ddd4b9e3f69f2c14b540d7439235f35 | |
# h2 is 6c5fda997ddd4b9e3f69f2c14b540d7439235f35 | |
# h1 == h2 ? True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment