January 2019
Intermediate to advanced
342 pages
9h 17m
English
CAPTCHAs can be generated using the Claptcha package in Python. We use this to generate CAPTCHA images of four characters consisting of numbers and text. Consequently, each character can be any one of 26 letters and 10 digits. The following code can be used for generating CAPTCHAs with a random selection of letters and digits:
alphabets = 'abcdefghijklmnopqrstuvwxyz'alphabets = alphabets.upper()font = "/home/santanu/Android/Sdk/platforms/android-28/data/fonts/DancingScript-Regular.ttf"# For each of the 4 characters determine randomly whether its a digit or alphabetchar_num_ind = list(np.random.randint(0,2,4))text = ''for ind in char_num_ind: if ind == 1: # for indicator 1 select character else number loc = np.random.randint(0,26,1) ...
Read now
Unlock full access