Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generateCaptcha(this, words_count = 4, _pre_render = ""):
- dicts = this.server.getCaptcha()
- words = []
- found = ""
- if _pre_render == "":
- while len(words) < words_count:
- randed = random.choice(dicts.keys())
- found += randed
- words += [randed]
- else:
- _pre_render = _pre_render.upper()
- _pre_x = 0
- while _pre_x < len(_pre_render):
- randed = _pre_render[_pre_x]
- found += randed
- words += [randed]
- _pre_x+=1
- last_y = 0
- for wordy in words:
- values = dicts[wordy]
- if last_y < len(values.keys()):last_y = len(values.keys())
- panel_x = 0
- posy = 1
- lines = []
- while posy < last_y:
- values = []
- wp = 1
- for word in words:
- wpy = posy
- wv = dicts[word]
- if wpy > len(wv.keys()):wpy = len(wv.keys())
- wlvs = wv[str(wpy)]
- cvp = 0
- if wp > 1:cvp = 1
- values += wlvs.split(",")[cvp:]
- wp+=1
- lines += [",".join(map(str, values))]
- if panel_x < len(values):panel_x = len(values)
- posy += 1
- c = byteArray()
- panel_x += 2
- c.writeShort(panel_x)
- c.writeShort(last_y)
- panel_tam = panel_x*last_y
- c.writeShort(panel_tam)
- for line in lines:
- c.writeInt(0)
- for vline in line.split(","):
- c.writeByte(int(vline))
- c.writeByte(0)
- c.writeByte(0)
- c.writeByte(0)
- c.writeInt(0)
- while (len(c.toByteArray())-6)/4 < panel_tam:c.writeInt(0)
- this.sendData("\x1a\x14" + c.toByteArray(), [], True)
- return found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement