Skip to content

Instantly share code, notes, and snippets.

@dylwylie
Last active December 30, 2015 18:13
Show Gist options
  • Save dylwylie/a73555686b6da3dd8873 to your computer and use it in GitHub Desktop.
Save dylwylie/a73555686b6da3dd8873 to your computer and use it in GitHub Desktop.
Uses pythons uuid library to generated uuids to see if they generate collisions. (Warning: Will use up your RAM)
import uuid
count = 0
collision = False
guid_dict = {}
while not collision:
guid = uuid.uuid4()
if not guid in guid_dict:
guid_dict[guid] = 1
else:
collision = True
print("Collision found!")
print("Collision found after " + str(count) + " loops")
print("Key: " + str(guid))
if count % 1000000 == 0:
print(str(count) + " Counts and no collision")
count = count + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment