Advertisement
Guest User

Captcha for proxy-anon

a guest
Apr 16th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. const express = require('express')
  2. const captchaGenerator = require('captchagen')
  3.  
  4. const port = 3000
  5.  
  6. const app = express()
  7.  
  8. app.get('/', (req, res) => {
  9. const russianAlphabet = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя'
  10. const captchaLength = 6
  11. let captchaText = ''
  12.  
  13. while (captchaText.length < captchaLength) {
  14. captchaText += russianAlphabet[Math.floor(Math.random() * russianAlphabet.length)]
  15. }
  16. const captcha = captchaGenerator.create({
  17. text: captchaText
  18. })
  19.  
  20. console.log(captcha.text())
  21.  
  22. captcha.generate()
  23.  
  24. res.set('Content-Type', 'image/png')
  25.  
  26. res.send(Buffer.from(captcha.buffer()))
  27. })
  28.  
  29. app.listen(port, () => {
  30. console.log(`Example app listening on port ${port}`)
  31. })
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement