In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "SpringBoot configuration google kaptcha CAPTCHA picture generation tool", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "SpringBoot configuration google kaptcha CAPTCHA picture generation tool"!
1. POM: com.github.axet kaptcha 0.0.92 and configuration parameter import com.google.code.kaptcha.impl.DefaultKaptcha;import com.google.code.kaptcha.util.Config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import java.util.Properties are introduced into the project. @ Configurationpublic class KaptchaConfig {/ * Google Captcha Configurable item 1 whether kaptcha.border has a border defaults to true. We can set the yes ourselves. No 2 kaptcha.border.color border color defaults to Color.BLACK 3 kaptcha.border.thickness border thickness defaults to 1 4 kaptcha.producer.impl CAPTCHA generator defaults to DefaultKaptcha 5 kaptcha.textproducer.impl CAPTCHA text generator defaults to DefaultTextCreator 6 kaptcha.textproducer.char.string CAPTCHA text text range defaults to abcde2345678gfynmnpwx 7 kaptcha.textproducer.char.length CAPTCHA text character length defaults to 58 kaptcha.textproducer.font.names CAPTCHA text font style defaults to new Font ("Arial" 1, fontSize), new Font ("Courier", 1 FontSize) 9 kaptcha.textproducer.font.size CAPTCHA text character size defaults to 40 10 kaptcha.textproducer.font.color CAPTCHA text character color defaults to Color.BLACK 11 kaptcha.textproducer.char.space CAPTCHA text character spacing defaults to 2 12 kaptcha.noise.impl CAPTCHA noise generation object defaults to DefaultNoise 13 kaptcha.noise.color CAPTCHA noise color Color.BLACK 14 kaptcha.obscurificator.impl CAPTCHA style engine defaults to WaterRipple 15 kaptcha.word.impl CAPTCHA text character rendering defaults to DefaultWordRenderer 16 kaptcha.background.impl CAPTCHA background generator defaults to DefaultBackground 17 kaptcha.background.clear.from CAPTCHA background color progressive default to Color.LIGHT_GRAY 18 kaptcha.background.clear.to CAPTCHA background color progressive default For Color.WHITE 19 kaptcha.image.width CAPTCHA, the picture width defaults to 200 20 kaptcha.image.height CAPTCHA, and the picture height defaults to 50 verification / @ Bean public DefaultKaptcha producer () {Properties properties = new Properties () / / whether there is an optional yes or no properties.put ("kaptcha.border", "no"); / / CAPTCHA text character color properties.put ("kaptcha.textproducer.font.color", "black"); / / CAPTCHA text character spacing properties.put ("kaptcha.textproducer.char.space", "5") / / CAPTCHA text font style properties.put ("kaptcha.textproducer.font.names", "Arial,Courier,cmr10, Arial, italic, Microsoft Yahei"); Config config = new Config (properties); DefaultKaptcha defaultKaptcha = new DefaultKaptcha (); defaultKaptcha.setConfig (config); return defaultKaptcha;}} 3, test @ Autowired private Producer producer @ Test public void getCaptcha () {/ / generate text verification code String code = producer.createText (); System.out.println (code); / / cnxg2 / / generate picture BufferedImage image = producer.createImage (code); try {/ / store locally for easy observation OutputStream out = new FileOutputStream (new File ("D:/2.jpg")) ImageIO.write (image, "jpg", out); / / write the picture to the specified file} catch (Exception e) {e.printStackTrace ();}} 4, effect picture
You can see that the effect is very good!
Thank you for your reading, the above is the content of "SpringBoot configuration google kaptcha CAPTCHA picture generation tool". After the study of this article, I believe you have a deeper understanding of the problem of SpringBoot configuring google kaptcha CAPTCHA picture generation tool, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.