I want to create unique <client-key>
and <client-secret>
for users who register for the service.
So, I searched the same and came up with the following options:
This is a stupid question, but I want to know which implementation is safer to use (with the right explanation)? What for? And what are the advantages of using it over others?
Note:
AFAIK, random.SystemRandom()
uses os.urandom(x)
. Therefore, the comparison is mainly done between uuid
and random.SystemRandom()
.
Here is what I have tried so far:
1)
import random temp = random.SystemRandom() random_seq = ''.join(temp.choice(CHARACTER_SET) for x in range(x)) >>> 'wkdnP3EWxtEQWnB5XhqgNOr5RKL533vO7A40hsin'
2)
import uuid str(uuid.uuid4()) >>> 'f26155d6-fa3d-4206-8e48-afe15f26048b'
I am not sure about the solution. So any help would be appreciated.
PS It would be great if any solution were available for both Python 2.x and 3.x.
source share