Last active
April 11, 2017 20:35
-
-
Save codl/7eb869e96fa55a2805594ad60acf0544 to your computer and use it in GitHub Desktop.
whoops lol
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 hashlib | |
| import random | |
| import matplotlib.pyplot as plt | |
| DOMAIN_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz-." | |
| def make_random_md5s(count, prefix=""): | |
| sets = [] | |
| for _ in range(count): | |
| inputt = prefix | |
| for _ in range(15): # im gonna assume 15 chars is average domain length | |
| inputt += random.choice(DOMAIN_CHARS) | |
| sets += [(inputt, hashlib.md5(bytes(inputt, "UTF-8")).hexdigest()[:6])] | |
| return sets | |
| if __name__ == "__main__": | |
| print("generating 100k md5s with https:// prefix") | |
| with_prefix = make_random_md5s(100000, "https://") | |
| print("samples:", with_prefix[:2]) | |
| print("generating 100k md5s without prefix") | |
| without_prefix = make_random_md5s(100000, "") | |
| print("samples:", without_prefix[:2]) | |
| print("converting md5s to integers") | |
| prefix_values = list(int(t[1], 16) for t in with_prefix) | |
| noprefix_values = list(int(t[1], 16) for t in without_prefix) | |
| print("samples:", prefix_values[0], noprefix_values[0]) | |
| plt.hist((prefix_values, noprefix_values)) | |
| plt.legend(("with https://", "without a prefix")) | |
| plt.gca().get_xaxis().get_major_formatter().set_scientific(False); | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
