r/howdidtheycodeit • u/Beliriel • May 16 '23
Question How did they code the 4Chan Captcha?
Hi guys
I know, I know, sue for lurking around 4Chan. Nonetheless I come to you with a question regarding their CAPTCHA. It's two pictures on top of each other with the top one having 3 to 4 "transparent holes" and you need to align the bottom picture with the top one to reveal the letters and solve it. I find this design rather nice and would also like to understand and incorporate it somewhere on my own website. I'm limited to PHP (and possibly javascript for dynamically aligning pictures) so I wonder if something like this was possible with simple tech like that. Can PHP generate pictures like these? Any help would be much appreciated.
12
u/AdarTan May 16 '23
PHP has image generation functions. You create an image with one of the
imagecreate*functions and then use the other functions to manipulate that image. When drawing you are going to have to pay attention to the blending mode set with theimagealphablendingfunction if you want to create a transparent area.The generated image gets set as the CSS background-image of an appropriate element and the scrolling is achieved by manipulating the
background-positionproperties of that element via javascript.Then you place another image, that has transparent holes painted on it over the first image.
14
u/andyandcomputer May 16 '23
What the fuck does that even say?
≈;XyP̄🮡2YrM→╵8~???Edit: Oh, I guess it's supposed to be interactively animated or something, not a static image like the screenshot.
17
u/suckitphil May 16 '23
Pretty sure they just use a regular captcha but then just slice the image 10 times or so. Just offset the image by x. Then just check whether the slider matches the offset +-5 pixels.