-
Notifications
You must be signed in to change notification settings - Fork 20
/
CAPTCHA
25 lines (17 loc) · 667 Bytes
/
CAPTCHA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# pip install captcha
# modificare questo
# https://github.com/lepture/captcha/blob/master/captcha/image.py
import random
import string
from captcha.audio import AudioCaptcha
from captcha.image import ImageCaptcha
CAPTCHA_FONTS = ['/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
'/usr/share/fonts/truetype/liberation/LiberationMono-Italic.ttf']
#audio = AudioCaptcha(voicedir='/path/to/voices')
image = ImageCaptcha(fonts=CAPTCHA_FONTS)
#data = audio.generate('1234')
#audio.write('1234', 'out.wav')
text = [random.choice(string.ascii_letters) for i in range(5)]
data = image.generate(text)
#data.read()
image.write(text, 'out.png')