Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to simply generate random CAPTCHA for Mini Program

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The editor of this article introduces in detail "how Mini Program can simply generate random CAPTCHA". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to generate random CAPTCHA by Mini Program" can help you solve your doubts.

/ / randomly generate CAPTCHA / / first step: public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {test (response);} private void test (HttpServletResponse response) throws IOException {int width = 120 / / generate a picture and get a black picture with a width of 120 and a length of 25 BufferedImage img = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); Graphics grap = img.getGraphics (); / / get a brush / / fill in the background color grap.setColor (Color.pink) / / set the filled area grap.fillRect (1, 1, width-2, height-2); / / set the border color and fill background color close to who is the color of which property grap.setColor (Color.red); grap.drawRect (0,0, width-1, height-1) / / set the font grap.setFont (new Font ("boldface", Font.BOLD | Font.ITALIC, 18)); / / write to the picture. Hey hey randomly generated the string Random r = new Random (); int p = 15; for (int iTunes 1)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report