mbi / django-simple-captcha

Django Simple Captcha is an extremely simple, yet highly customizable Django application to add captcha images to any Django form.
http://django-simple-captcha.readthedocs.io/en/latest/
MIT License
1.38k stars 319 forks source link

Not generate the same image with the same key problem. #223

Open zencore-dobetter opened 11 months ago

zencore-dobetter commented 11 months ago

captcha/views.py:50

random.seed(key) # Do not generate different images for the same key

This random.seed(key) can NOT ensure to generate the same images at high concurrent requests scenario. Suggest to use private_random_generator = random.Random(key) to create a function private random generator, and use private_random_generator.choices and private_random_generator.randrange in the image generate function.

zencore-dobetter commented 11 months ago

And needs to pass the private_random_generator to the noise_functions and maybe also filter_functions.