WO2016124066A1 - Image verification code generation method and system - Google Patents

Image verification code generation method and system Download PDF

Info

Publication number
WO2016124066A1
WO2016124066A1 PCT/CN2016/070553 CN2016070553W WO2016124066A1 WO 2016124066 A1 WO2016124066 A1 WO 2016124066A1 CN 2016070553 W CN2016070553 W CN 2016070553W WO 2016124066 A1 WO2016124066 A1 WO 2016124066A1
Authority
WO
WIPO (PCT)
Prior art keywords
picture
verification code
font
character
characters
Prior art date
Application number
PCT/CN2016/070553
Other languages
French (fr)
Chinese (zh)
Inventor
赵志猛
罗治凡
闪光辉
刘深
Original Assignee
北京京东尚科信息技术有限公司
北京京东世纪贸易有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京京东尚科信息技术有限公司, 北京京东世纪贸易有限公司 filed Critical 北京京东尚科信息技术有限公司
Publication of WO2016124066A1 publication Critical patent/WO2016124066A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/31User authentication
    • G06F21/36User authentication by graphic or iconic representation

Definitions

  • the picture is determined according to a picture color and a picture resolution included in the verification code parameter.
  • the interference line adding module 305 is configured to: generate at least one interference line on the picture to obtain a picture verification code, where the trajectory of the interference line is randomly generated.
  • the twisting process includes: selecting at least one portion on each of the rendered characters as a portion to be twisted, and performing an upward translation, a downward translation, a left translation, or Pan to the right.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Image Analysis (AREA)

Abstract

An image verification code generation method and system, the method comprising: randomly selecting, from a character set, a set of character strings comprising a plurality of characters, lengths of the character strings being randomly determined (S101); randomly selecting a font from a font set for each character in the character strings, and rendering to obtain rendered characters, the fonts in a font library being a set of size n × m comprising n fonts and m word sizes, and n and m being preset natural numbers (S102); distorting each of the rendered characters to obtain distorted characters (S103); generating an image comprising a plurality of the distorted characters (S104); and generating at least one interference line on the image to obtain an image verification code, a path of the interference line being randomly generated (S105). The method improves user experience of the verification code, increases the difficulty of recognizing the verification code by a computer, and effectively ensures system security.

Description

一种图片验证码生成方法及系统Image verification code generation method and system 技术领域Technical field
本发明涉及验证码相关技术领域,特别是一种图片验证码生成方法及系统。The present invention relates to the field of verification code related technologies, and in particular, to a picture verification code generation method and system.
背景技术Background technique
因为简单易用等原因,现在互联网中主流的验证码是图片验证码。图片验证码与图像处理技术息息相关,如:字符的嵌入、噪音的添加等,需要用到基本的图像处理知识。而图片验证码的破解就显得比较的复杂,它不仅需要专业的图片处理知识,还需要人工智能方面的知识,不过,随着人工智能的发展以及开源工具的流行,简单的图片验证码识别变得也越来越容易。Because of the ease of use and other reasons, the mainstream verification code in the Internet is now the picture verification code. Image verification code is closely related to image processing technology, such as embedding of characters, addition of noise, etc., and basic image processing knowledge is required. The cracking of the image verification code is more complicated. It requires not only professional image processing knowledge, but also knowledge of artificial intelligence. However, with the development of artificial intelligence and the popularity of open source tools, simple image verification code recognition It is getting easier and easier.
目前,图片验证码的设计以图片内容大致可以分为以下三种:At present, the design of image verification code can be roughly divided into the following three types:
(1)使用最基本的、最流行是一种以随机字符、数字作为图片内容的验证码。这种验证码字符长度通常都是固定的(长度为4),在随机字符的情况下可以根据需要添加相应的干扰元素,比如:背景色、干扰线等。在这种验证码系统中,根据干扰元素特征又可以分为两种:1、采用相对固定的干扰因素。这种验证码干扰元素肉眼看起来变化挺大,但是对计算机来说变化不大,比如背景色,即使背景色不断变化,但是一般都是很容易去除的;再比如说字符的位置甚至字体都是固定或者字符串整体左右漂移的,其实对于计算机来说都很容易找到字符所在区域,这种验证码破解比较容易。2、干扰因素出现有一定的随机性。这种验证码干扰因素有了较大的随机性,比如干扰线的位置、字符的字体、字符的相对位置、字符旋转角度等都是在不断的变化,但是这种验证码用户体验一般都不是太好,比如字符旋转,通常情况下字符选装方向以及角度都是不固定的,肉眼识别的时候需要人们下意识的把头左右倾斜才能看清楚;字符字体的变化通常都是在不同图片中采 用不同的字体方式,而同一张图片中的字体大多都是一样的,即使是采用多种字体,比如:中空字体、实心字体、上下两色处理、阴影处理等,其实这些无非是把几种验证码合并到了一块,前后两张图片的差别太大,影响用户体验。(1) The most basic and most popular use is a verification code with random characters and numbers as picture content. The length of this verification code character is usually fixed (length is 4). In the case of random characters, corresponding interference elements such as background color, interference line, etc. can be added as needed. In this verification code system, according to the characteristics of the interference elements, it can be divided into two types: 1. A relatively fixed interference factor is adopted. This kind of verification code interference element looks quite big to the naked eye, but it doesn't change much to the computer, such as the background color. Even if the background color changes constantly, it is usually very easy to remove; for example, the position of the character or even the font It is fixed or the whole character of the string drifts left and right. In fact, it is easy for the computer to find the area where the character is located. This kind of verification code is easier to crack. 2. Interference factors have a certain randomness. This kind of verification code interference factor has a large randomness, such as the position of the interference line, the font of the character, the relative position of the character, the rotation angle of the character, etc. are constantly changing, but the user experience of this verification code is generally not Too good, such as character rotation, usually the character selection direction and angle are not fixed. When the naked eye recognizes, people need to subconsciously tilt the head left and right to see clearly; the change of character font is usually taken in different pictures. Different font styles, and most of the fonts in the same picture are the same, even if using a variety of fonts, such as: hollow fonts, solid fonts, upper and lower color processing, shadow processing, etc., in fact, these are nothing more than The verification code is merged into one piece, and the difference between the two pictures is too large, which affects the user experience.
(2)以专业知识作为图片内容的验证码。比如:数学专业性比较强网站可以采用数学中常用的积分来作为验证码内容,验证码需要积分的结果;电子类专业性比较强的网站可以采用类似“电流的单位是欧姆”你只需要判断正确性就行。(2) Use professional knowledge as the verification code for the picture content. For example: a relatively strong professional mathematics website can use the points commonly used in mathematics as the content of the verification code, and the verification code needs the result of the integration; the website with strong professionalism can use a similar "current unit is ohm". You only need to judge Correctness will do.
(3)以复杂的图像作为验证码内容。比如一幅完整的带有图案的图片,中间对一个圆形区域做一定的旋转,验证时需要旋转中间的区域使图案复原成一幅完整的图像算验证正确;或者是一种带有几只小狗的图案,你需要回答图案中有小狗的等。(3) Use complex images as the content of the verification code. For example, a complete picture with a pattern, the middle of a circular area to do a certain rotation, the verification needs to rotate the middle area to restore the pattern into a complete image to verify correct; or a small with a few small Dog pattern, you need to answer the puppy in the pattern.
现有技术方案的缺点Disadvantages of prior art solutions
现有的看似较为复杂的干扰因素其实对计算机起到的干扰作用非常小,而某些看似简单的干扰因素计算机却很难识别。对于传统的图片验证码系统来说,背景色所起到的作用几乎可以忽略不计,为了肉眼能较好的识别,字符的颜色肯定要和背景色明显的区分开,如果不能很好的区分开,人肉眼识别的难度就会很大影响用户体验,但是如果背景色容易区分的话,那么那些看似复杂的背景色对于计算机来说非常容易,这样背景色就起不到应有的作用,并且复杂的背景色对一些色弱、色盲用户具有严重的干扰作用,不利于他们的使用;一些验证码采用字符扭曲作为干扰因素,现有的扭曲都是采用字符旋转的方式进行的,由于每个字符选装的方向不一样,这样肉眼识别的时候就会较为困难;The existing seemingly complicated interference factors actually have very little interference on the computer, and some seemingly simple interference factors are difficult to identify. For the traditional picture verification code system, the effect of the background color is almost negligible. In order to be better recognized by the naked eye, the color of the character must be clearly distinguished from the background color, if it is not well distinguished. The difficulty of human visual recognition will greatly affect the user experience, but if the background color is easy to distinguish, then those seemingly complicated background colors are very easy for the computer, so the background color will not function as it should, and Complex background colors have serious interference effects on some weak and color-blind users, which is not conducive to their use; some verification codes use character distortion as a disturbance factor, and existing distortions are performed by character rotation, because each character The orientation of the options is different, so it will be more difficult to identify with the naked eye;
对于一些复杂的验证码,比如每个字符都有扭曲,而且每个字符的扭曲力度、方向都不相同,这种验证码机器的确很难识别,但是人肉眼的识别难度很高,不利于用户体验,这些显然不利于用户的体验, 毕竟网络系统是服务于人的,系统的第一作用应该是提供服务,而不是去防止别人去非法使用它。For some complex verification codes, such as each character is distorted, and the distortion strength and direction of each character are different, this verification code machine is difficult to identify, but the recognition of human eyes is very difficult, which is not conducive to users. Experience, these are obviously not conducive to the user experience, After all, the network system is to serve people. The first role of the system should be to provide services, not to prevent others from illegally using it.
发明内容Summary of the invention
基于此,有必要针对现有技术未能提供一种肉眼更容易识别,但是计算机更难以破解的图片验证码的生成方式的技术问题,提供一种图片验证码生成方法及系统。Based on this, it is necessary to provide a method and system for generating a picture verification code, in view of the technical problem that the prior art fails to provide a picture verification code that is more easily recognized by the naked eye but is more difficult to be solved by the computer.
一种图片验证码生成方法,包括:A picture verification code generation method includes:
字符串选择步骤,包括:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;The string selection step includes: randomly selecting, from the character set, a set of characters including a plurality of characters, the length of the string being randomly determined;
字体渲染步骤,包括:对所述字符串所包括的每个字符从字体集中随机选择一种字体和字号进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号,所述n和m为预设的自然数;The font rendering step includes: randomly selecting a font and a font size from a font set for each character included in the string to perform rendering processing, and the font library includes a plurality of fonts, and each font has multiple types. Font size, the n and m are preset natural numbers;
字体扭曲步骤,包括:对每个所述渲染字符进行扭曲处理得到扭曲字符;The font warping step includes: twisting each of the rendered characters to obtain a twisted character;
图片预生成步骤,包括:生成包括多个所述扭曲字符的图片;a picture pre-generation step, comprising: generating a picture including a plurality of the twisted characters;
干扰线添加步骤,包括:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。The interference line adding step includes: generating at least one interference line on the picture to obtain a picture verification code, and the trajectory of the interference line is randomly generated.
一种图片验证码生成系统,包括:A picture verification code generation system includes:
字符串选择模块,用于:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;a string selection module, configured to: randomly select a group of characters including a plurality of characters from a character set, and the length of the string is randomly determined;
字体渲染模块,用于:对所述字符串所包括的每个字符从字体集中随机选择一种字体和字号进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号;a font rendering module, configured to: randomly select a font and a font size from a font set to render characters for each character included in the character string, where the font library includes multiple fonts, and each font has multiple fonts. Kind size
字体扭曲模块,用于:对每个所述渲染字符进行扭曲处理得到扭曲字符;a font warping module, configured to: perform distortion processing on each of the rendered characters to obtain a twisted character;
图片预生成模块,用于:生成包括多个所述扭曲字符的图片; a picture pre-generation module, configured to: generate a picture including a plurality of the twisted characters;
干扰线添加模块,用于:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。The interference line adding module is configured to: generate at least one interference line on the picture to obtain a picture verification code, and the trajectory of the interference line is randomly generated.
本发明的干扰元素仅仅使用肉眼容易识别的干扰线、以及对字符进行扭曲而不是进行字符的旋转,这些因素很大程度的提高了验证码的用户体验;而字符长度的不固定、干扰线轨迹的不固定、字符字体不同则增大了计算机识别验证码的难度,有效的保证了系统的安全性。The interference element of the present invention uses only the interference line easily recognized by the naked eye, and the distortion of the character instead of the rotation of the character. These factors greatly improve the user experience of the verification code; while the length of the character is not fixed, the interference line trajectory The unfixed characters and different fonts increase the difficulty of the computer identification verification code, which effectively ensures the security of the system.
附图说明DRAWINGS
图1为本发明一种图片验证码生成方法的工作流程图;1 is a flowchart of a method for generating a picture verification code according to the present invention;
图2为本发明的最佳实施例的工作流程图;Figure 2 is a flow chart showing the operation of a preferred embodiment of the present invention;
图3为本发明一种图片验证码生成系统的结构模块图。FIG. 3 is a structural block diagram of a picture verification code generating system according to the present invention.
具体实施方式detailed description
下面结合附图和具体实施例对本发明做进一步详细的说明。The present invention will be further described in detail below in conjunction with the drawings and specific embodiments.
如图1所示为本发明一种图片验证码生成方法的工作流程图,包括:FIG. 1 is a flowchart of a method for generating a picture verification code according to the present invention, including:
步骤S101,包括:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;Step S101, comprising: randomly selecting, from the character set, a set of character strings including a plurality of characters, where the length of the character string is randomly determined;
步骤S102,包括:对所述字符串所包括的每个字符从字体集中随机选择一种字体和字号进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号;Step S102 includes: randomly selecting a font and a font size from a font set for each character included in the character string, and performing rendering processing to obtain a rendered character, where the font library includes multiple fonts, and each font has multiple font sizes. ;
步骤S103,包括:对每个所述渲染字符进行扭曲处理得到扭曲字符;Step S103, comprising: performing distortion processing on each of the rendered characters to obtain a twisted character;
步骤S104,包括:生成包括多个所述扭曲字符的图片;Step S104, comprising: generating a picture including a plurality of the twisted characters;
步骤S105,包括:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。Step S105, comprising: generating at least one interference line on the picture to obtain a picture verification code, and the trajectory of the interference line is randomly generated.
其中,步骤S101中,字符集优选地为经过筛选的由数字、字母组 成的字符串,中间去除了在图片中易混淆的字符,比如I和1、6和b等。Wherein, in step S101, the character set is preferably a filtered number, a group of letters A string of characters that removes confusing characters in the picture, such as I and 1, 6, and b.
步骤S102中,字体集包括n种字体,且每种字体具有m种字号,例如可以是:小三字号的楷体、小三字号的宋体、小三字号的圆体、三号字号的楷体、三号字号的宋体、三号字号的圆体、小四字号的楷体、小四字号的宋体、小四字号的圆体等。对于每个字符串,例如:4B69,其包括的字符为:4、B、6、9,对每个字符分别选择一个字体和字号,例如:4选择小三大小的楷体,B选择三号字号的圆体、6选择小四字号的圆体、9选择三号字号的宋体,则每个字符的字号及字体都不同,对于不同字号不同字体的字符,人的肉眼会很容易识别,而机器由于需要提取特征进行识别,当字号不同所选用的字体不同时,其所需要针对不同字号不同的字体进行特征提取,且不同的字符所选择的字体和字号均为随机,机器识别的难度大大增加。In step S102, the font set includes n types of fonts, and each font has m font sizes, for example, a small three-character font, a small three-character Song, a small three-character, a third-sized font, and a third font. The body of the Song, the size of the third size, the body of the small four-character, the Song of the small four-character, and the circle of the small four-character. For each string, for example: 4B69, the characters included are: 4, B, 6, and 9. Select a font and a font size for each character, for example, 4 selects the small three-sized body, and B selects the third size. The round body, 6 selects the small quadrilateral circle, and 9 selects the 3rd font size. The font size and font of each character are different. For different font sizes and different font characters, the human eye will be easily recognized, and the machine is It is necessary to extract features for recognition. When the fonts selected by different font sizes are different, it is necessary to extract features for different fonts with different font sizes, and the fonts and font numbers selected by different characters are random, and the difficulty of machine recognition is greatly increased.
步骤S103中对字符的扭曲,则只是对字符形状的扭曲,而不是将字符进行旋转,由于只是对字符形状进行的扭曲,人的肉眼仍然能够进行识别,但对于机器来说,由于其不知道字符形状做了什么样的扭曲,其特征无从选择,难度大大提高。The distortion of the character in step S103 is only a distortion of the shape of the character, instead of rotating the character, since the distortion of the shape of the character is only possible, the human eye can still recognize, but for the machine, since it does not know What kind of distortion is made in the character shape, its characteristics are not available, and the difficulty is greatly improved.
步骤S104中所增加的干扰线,对于肉眼来说能很好地将其与验证码区分,但对机器来说,所增加的干扰线会导致其对字符的识别时无法提取合适特征,从而导致识别难度增大。The interference line added in step S104 can be well distinguished from the verification code for the naked eye, but for the machine, the added interference line will cause the recognition of the character to be unable to extract suitable features, resulting in The difficulty of recognition increases.
本发明的干扰元素仅仅使用肉眼容易识别的干扰线、以及对字符进行扭曲而不是进行字符的旋转,这些因素很大程度的提高了验证码的用户体验;而字符长度的不固定、干扰线轨迹的不固定、字符字体不同则增大了计算机识别验证码的难度,有效的保证了系统的安全性。The interference element of the present invention uses only the interference line easily recognized by the naked eye, and the distortion of the character instead of the rotation of the character. These factors greatly improve the user experience of the verification code; while the length of the character is not fixed, the interference line trajectory The unfixed characters and different fonts increase the difficulty of the computer identification verification code, which effectively ensures the security of the system.
在其中一个实施例中: In one of the embodiments:
还包括验证码参数获取步骤,所述验证码参数获取步骤包括:响应于验证码提供请求,根据所述验证码提供请求所包括的应用标识,获取所述应用标识所对应的验证码参数,所述验证码参数包括字符串的最小允许长度和最大允许长度、图片颜色和图片分辨率;And a verification code parameter obtaining step, the verification code parameter obtaining step includes: obtaining, according to the verification code providing request, the application identifier included in the verification code providing request, and acquiring the verification code parameter corresponding to the application identifier, The verification code parameters include a minimum allowable length and a maximum allowable length of the character string, a picture color, and a picture resolution;
且所述字符串选择步骤中,所述字符串的长度在所述最小允许长度和最大允许长度之间随机确定;And in the string selection step, the length of the character string is randomly determined between the minimum allowable length and the maximum allowable length;
且所述图片预生成步骤中,所述图片根据所述验证码参数所包括的图片颜色和图片分辨率确定。And in the picture pre-generation step, the picture is determined according to a picture color and a picture resolution included in the verification code parameter.
本实施例增强了验证码系统的通用性,因为实际运用中一套验证码会应用于多个系统,但是,为了更好的用户体验机安全性需要,不同的系统有时候所需要的特征参数不同,比如移动端所需要的图片大小会根据分辨率的不同而不同,图片的颜色会根据主题色的变化而变化,所以需要一个容易操作的配置系统针对不同的应用进行个性化的参数设置,从而使验证码系统可以应用与多个应用,并且参数的配置完全可以线上随机随时改变,增强了系统风控的灵活性。This embodiment enhances the versatility of the verification code system, because a set of verification codes will be applied to multiple systems in actual operation, but the characteristic parameters sometimes required by different systems for better user experience machine security needs. Different, for example, the size of the image required by the mobile terminal will vary according to the resolution. The color of the image will change according to the theme color, so an easy-to-operate configuration system is required for personalization of different applications. Therefore, the verification code system can be applied to multiple applications, and the configuration of the parameters can be completely changed at random on the line, which enhances the flexibility of the system wind control.
本实施例中,针对不同的应用,可以预先设置不同的验证码参数,从而控制字符串的长度、图片颜色和图片分辨率等。In this embodiment, different verification code parameters may be set in advance for different applications, thereby controlling the length of the character string, the color of the picture, and the resolution of the picture.
在其中一个实施例中,所述扭曲处理包括:在每个所述渲染字符上选择至少一个部位作为待扭曲部位,在每个所述待扭曲部位进行向上平移、向下平移、向左平移或向右平移。In one embodiment, the twisting process includes: selecting at least one portion on each of the rendered characters as a portion to be twisted, and performing an upward translation, a downward translation, a left translation, or Pan to the right.
本实施例中,对字符串的扭曲不是对字符的旋转而是对字符不同部位上下、左右式的平移,优选地,该平移为光滑平移。由于只是对字符的不同部位做平移,对于肉眼来说,仍然能够很好地识别,但是对机器来说,由于机器一般都是进行特征识别,也就是对图片上与背景颜色区别明显的颜色,在其上提取多个不同的点作为特征点,然后根据特征点所在的位置,从数据库中选择特征点相同或相类似的字。 然而,采用本实施例的扭曲方式后,验证码的特征点的位置已经做出改变,而且所改变的特征点是随机选择,因此,机器很难对其进行识别。In this embodiment, the distortion of the character string is not a rotation of the character but a translation of the upper and lower sides of the different parts of the character, preferably, the translation is a smooth translation. Since only the different parts of the character are translated, it is still well recognized by the naked eye, but for the machine, since the machine generally performs feature recognition, that is, the color that is distinct from the background color on the picture, A plurality of different points are extracted as feature points thereon, and then the same or similar words of the feature points are selected from the database according to the location of the feature points. However, with the twisting method of the present embodiment, the position of the feature point of the verification code has been changed, and the changed feature point is randomly selected, so that it is difficult for the machine to recognize it.
在其中一个实施例中,每条所述干扰线采用如下方式生成:In one of the embodiments, each of the interference lines is generated as follows:
在所述图片上随机选择多个轨迹点,生成包括所有所述轨迹点的多次方程轨迹。A plurality of track points are randomly selected on the picture to generate a plurality of equation tracks including all of the track points.
优选地,干扰线采用图片中的四个随机点确定一条三次方程轨迹。增加了干扰线,由于机器并不知道其体是什么样的字体,其识别时只能提取特征点,因此增加干扰线,相当于增加了机器识别时的特征点,但所增加的特征点并不是验证码的实际特征点,因此机器很难对其识别。Preferably, the interference line determines a cubic equation trajectory using four random points in the picture. The interference line is added. Since the machine does not know what kind of font its body is, it can only extract feature points when it is recognized. Therefore, adding interference lines is equivalent to increasing the feature points when the machine recognizes, but the added feature points are It is not the actual feature point of the verification code, so it is difficult for the machine to recognize it.
通过多个点确定一个多次方程轨迹的方式,可以采用现有技术实现,例如java库里面的工具类实现。The way to determine a multi-equation trajectory through multiple points can be implemented by the prior art, such as the tool class implementation in the java library.
在其中一个实施例中,所述干扰线与所述字符的颜色相同,且所述干扰线的粗细所有所述扭曲字符的最大宽度和最小宽度之间渐变。In one of the embodiments, the interference line is the same color as the character, and the thickness of the interference line is gradually changed between a maximum width and a minimum width of all the twisted characters.
本实施例中,干扰线的颜色与字符颜色相同,则机器更加难以识别,而且干扰线的粗细为渐变,也更加提高了机器的识别难度。In this embodiment, the color of the interference line is the same as the color of the character, the machine is more difficult to recognize, and the thickness of the interference line is gradual, which further improves the recognition difficulty of the machine.
如图2所示为本发明的最佳实施例的工作流程图,包括:2 is a flow chart showing the operation of a preferred embodiment of the present invention, including:
步骤S201,获取为用户提供验证码的请求;Step S201, obtaining a request for providing a verification code for the user;
步骤S202,根据请求信息从配置系统(Configuration Management System,CMS)获取相应验证码参数。验证码参数可以为:字符最大长度和最小长度、图片颜色、图片有效时间、两次图片请求至今的最小间隔等,验证码的生成是在相关的参数控制下进行的。 Step S202: Acquire corresponding verification code parameters from a configuration management system (CMS) according to the request information. The verification code parameters can be: the maximum length and minimum length of the character, the color of the picture, the effective time of the picture, the minimum interval between the two picture requests, and so on. The generation of the verification code is performed under the control of related parameters.
步骤S203,随机字符串生成。在字符集中随机选出相应长度的字符串作为随机字符串,随机字符串的长度在字符最大长度和最小长度之间随机选择。这个字符集是经过筛选的由数字、字母组成的字符串,中间去除了在图片中易混淆的字符,比如I和1、6和b等。In step S203, a random string is generated. A character string of a corresponding length is randomly selected in the character set as a random character string, and the length of the random string is randomly selected between the maximum length and the minimum length of the character. This character set is a filtered string of numbers and letters, which removes characters that are confusing in the picture, such as I and 1, 6, and b.
步骤S204,随机字符串渲染。Step S204, random string rendering.
从CMS中读取图片的长度和宽度生成相应大小的背景图片,并在背景图片上渲染上述随机字符串。在渲染的过程中随机字符串的每个字符都随机的从字体集中选出一种字体进行初始化,字体集中字体是由n种字体、m种字号组成的n×m大小的集合;经过字体的渲染之后会对每一个字符做扭曲处理,这里的扭曲不是对字符的旋转而是对字符不同部位上下、左右式的光滑平移;在渲染的过程中字符中间会根据情况保留一定的间距,当间距为负时说明两字符粘连;这样能避免传统的字符旋转带来的用户体验不佳问题,而且能保证字符肉眼识别具有较高的识别率。The length and width of the image are read from the CMS to generate a background image of the corresponding size, and the random string is rendered on the background image. During the rendering process, each character of the random string is randomly selected from the font set to be initialized. The font in the font set is a collection of n×m size consisting of n fonts and m font sizes; After rendering, each character will be distorted. The distortion here is not the rotation of the character but the smooth translation of the upper and lower sides of the character. In the process of rendering, the character will retain a certain spacing according to the situation. When it is negative, it indicates two-character adhesion; this can avoid the problem of poor user experience caused by traditional character rotation, and can ensure that the character recognition of the character has a higher recognition rate.
步骤S205,干扰线生成。干扰线会作为干扰元素添加到步骤S204生成的图片中,其中,每一条干扰线都是由图片中的四个随机点确定的一条三次方程轨迹,干扰线的长度与图片的宽度、长度有关,并且由于是由四个随机点所确定,因此其轨迹会随机变化。干扰线与字符同色,且干扰线粗细都在一定的范围内渐变,并且保证线条的宽度在字符的最大宽度和最小宽度之间,这样能防止验证码破解过程中干扰线的去除,从而保证验证码破解的难度。In step S205, the interference line is generated. The interference line is added as an interference element to the picture generated in step S204, wherein each interference line is a cubic equation track determined by four random points in the picture, and the length of the interference line is related to the width and length of the picture. And because it is determined by four random points, its trajectory will change randomly. The interference line is the same color as the character, and the thickness of the interference line is gradually changed within a certain range, and the width of the line is ensured between the maximum width and the minimum width of the character, which can prevent the removal of the interference line during the verification code cracking, thereby ensuring verification. The difficulty of code cracking.
如图3所示为本发明一种图片验证码生成系统的结构模块图,包括:FIG. 3 is a structural block diagram of a picture verification code generation system according to the present invention, including:
字符串选择模块301,用于:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;The character string selection module 301 is configured to: randomly select, from the character set, a set of character strings including a plurality of characters, where the length of the character string is randomly determined;
字体渲染模块302,用于:对所述字符串所包括的每个字符从字 体集中随机选择一种字体和字号进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号;a font rendering module 302, configured to: select each character included in the character string from the word The font set randomly selects a font and a font size for rendering processing to obtain rendered characters, the font library includes a plurality of fonts, and each font has a plurality of font sizes;
字体扭曲模块303,用于:对每个所述渲染字符进行扭曲处理得到扭曲字符;a font warping module 303, configured to: perform distortion processing on each of the rendered characters to obtain a twisted character;
图预生成模块304,用于:生成包括多个所述扭曲字符的图片;The image pre-generation module 304 is configured to: generate a picture including a plurality of the twisted characters;
干扰线添加模块305,用于:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。The interference line adding module 305 is configured to: generate at least one interference line on the picture to obtain a picture verification code, where the trajectory of the interference line is randomly generated.
在其中一个实施例中:In one of the embodiments:
还包括验证码参数获取模块,所述验证码参数获取模块用于:响应于验证码提供请求,根据所述验证码提供请求所包括的应用标识,获取所述应用标识所对应的验证码参数,所述验证码参数包括字符串的最小允许长度和最大允许长度、图片颜色和图片分辨率;And a verification code parameter obtaining module, configured to: in response to the verification code providing request, obtain an application identifier included in the request according to the verification code, and obtain a verification code parameter corresponding to the application identifier, The verification code parameter includes a minimum allowable length and a maximum allowable length of the character string, a picture color, and a picture resolution;
且所述字符串选择模块中,所述字符串的长度在所述最小允许长度和最大允许长度之间随机确定;And in the string selection module, the length of the character string is randomly determined between the minimum allowable length and the maximum allowable length;
且所述图片预生成模块中,所述图片根据所述验证码参数所包括的图片颜色和图片分辨率确定。And in the picture pre-generation module, the picture is determined according to a picture color and a picture resolution included in the verification code parameter.
在其中一个实施例中,所述扭曲处理包括:在每个所述渲染字符上选择至少一个部位作为待扭曲部位,在每个所述待扭曲部位进行向上平移、向下平移、向左平移或向右平移。In one embodiment, the twisting process includes: selecting at least one portion on each of the rendered characters as a portion to be twisted, and performing an upward translation, a downward translation, a left translation, or Pan to the right.
在其中一个实施例中,每条所述干扰线采用如下方式生成:In one of the embodiments, each of the interference lines is generated as follows:
在所述图片上随机选择多个轨迹点,生成包括所有所述轨迹点的多次方程轨迹。A plurality of track points are randomly selected on the picture to generate a plurality of equation tracks including all of the track points.
在其中一个实施例中,所述干扰线与所述字符的颜色相同,且所述干扰线的粗细所有所述扭曲字符的最大宽度和最小宽度之间渐变。In one of the embodiments, the interference line is the same color as the character, and the thickness of the interference line is gradually changed between a maximum width and a minimum width of all the twisted characters.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具 体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。 The above described embodiments only express several embodiments of the present invention, and the description thereof is more The invention is not to be construed as limiting the scope of the invention. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the invention. Therefore, the scope of the invention should be determined by the appended claims.

Claims (10)

  1. 一种图片验证码生成方法,包括:A picture verification code generation method includes:
    字符串选择步骤,包括:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;The string selection step includes: randomly selecting, from the character set, a set of characters including a plurality of characters, the length of the string being randomly determined;
    字体渲染步骤,包括:对所述字符串所包括的每个字符从字体集中随机选择一种字体和字体进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号;The font rendering step includes: randomly selecting a font and a font from a font set to perform rendering processing on each character included in the character string, the font library includes a plurality of fonts, and each font has multiple types. Font size
    字体扭曲步骤,包括:对每个所述渲染字符进行扭曲处理得到扭曲字符;The font warping step includes: twisting each of the rendered characters to obtain a twisted character;
    图片预生成步骤,包括:生成包括多个所述扭曲字符的图片;a picture pre-generation step, comprising: generating a picture including a plurality of the twisted characters;
    干扰线添加步骤,包括:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。The interference line adding step includes: generating at least one interference line on the picture to obtain a picture verification code, and the trajectory of the interference line is randomly generated.
  2. 根据权利要求1所述的图片验证码生成方法,其中:The picture verification code generating method according to claim 1, wherein:
    还包括验证码参数获取步骤,所述验证码参数获取步骤包括:响应于验证码提供请求,根据所述验证码提供请求所包括的应用标识,获取所述应用标识所对应的验证码参数,所述验证码参数包括字符串的最小允许长度和最大允许长度、图片颜色和图片分辨率;And a verification code parameter obtaining step, the verification code parameter obtaining step includes: obtaining, according to the verification code providing request, the application identifier included in the verification code providing request, and acquiring the verification code parameter corresponding to the application identifier, The verification code parameters include a minimum allowable length and a maximum allowable length of the character string, a picture color, and a picture resolution;
    且所述字符串选择步骤中,所述字符串的长度在所述最小允许长度和最大允许长度之间随机确定;And in the string selection step, the length of the character string is randomly determined between the minimum allowable length and the maximum allowable length;
    且所述图片预生成步骤中,所述图片根据所述验证码参数所包括的图片颜色和图片分辨率确定。And in the picture pre-generation step, the picture is determined according to a picture color and a picture resolution included in the verification code parameter.
  3. 根据权利要求1所述的图片验证码生成方法,其中,所述扭曲处理包括:在每个所述渲染字符上选择至少一个部位作为待扭曲部位,在每个所述待扭曲部位进行向上平移、向下平移、向左平移或向右平移。The picture verification code generating method according to claim 1, wherein the distortion processing comprises: selecting at least one part as a to-be-distorted portion on each of the rendered characters, and performing an upward shift on each of the to-be-distorted portions, Pan down, pan left, or pan right.
  4. 根据权利要求1所述的图片验证码生成方法,其中,每条所述 干扰线采用如下方式生成:The picture verification code generating method according to claim 1, wherein each of said pieces The interference line is generated as follows:
    在所述图片上随机选择多个轨迹点,生成包括所有所述轨迹点的多次方程轨迹。A plurality of track points are randomly selected on the picture to generate a plurality of equation tracks including all of the track points.
  5. 根据权利要求1所述的图片验证码生成方法,其中,所述干扰线与所述字符的颜色相同,且所述干扰线的粗细所有所述扭曲字符的最大宽度和最小宽度之间渐变。The picture verification code generating method according to claim 1, wherein the interference line is the same as the color of the character, and the thickness of the interference line is gradually changed between a maximum width and a minimum width of all the twisted characters.
  6. 一种图片验证码生成系统,包括:A picture verification code generation system includes:
    字符串选择模块,用于:从字符集中随机选出一组包括多个字符的字符串,所述字符串的长度随机确定;a string selection module, configured to: randomly select a group of characters including a plurality of characters from a character set, and the length of the string is randomly determined;
    字体渲染模块,用于:对所述字符串所包括的每个字符从字体集中随机选择一种字体和字号进行渲染处理得到渲染字符,所述字体库包括多种字体,且每种字体具有多种字号;a font rendering module, configured to: randomly select a font and a font size from a font set to render characters for each character included in the character string, where the font library includes multiple fonts, and each font has multiple fonts. Kind size
    字体扭曲模块,用于:对每个所述渲染字符进行扭曲处理得到扭曲字符;a font warping module, configured to: perform distortion processing on each of the rendered characters to obtain a twisted character;
    图片预生成模块,用于:生成包括多个所述扭曲字符的图片;a picture pre-generation module, configured to: generate a picture including a plurality of the twisted characters;
    干扰线添加模块,用于:在所述图片上生成至少一条干扰线得到图片验证码,所述干扰线的轨迹随机生成。The interference line adding module is configured to: generate at least one interference line on the picture to obtain a picture verification code, and the trajectory of the interference line is randomly generated.
  7. 根据权利要求6所述的图片验证码生成系统,其中:The picture verification code generating system according to claim 6, wherein:
    还包括验证码参数获取模块,所述验证码参数获取模块用于:响应于验证码提供请求,根据所述验证码提供请求所包括的应用标识,获取所述应用标识所对应的验证码参数,所述验证码参数包括字符串的最小允许长度和最大允许长度、图片颜色和图片分辨率;And a verification code parameter obtaining module, configured to: in response to the verification code providing request, obtain an application identifier included in the request according to the verification code, and obtain a verification code parameter corresponding to the application identifier, The verification code parameter includes a minimum allowable length and a maximum allowable length of the character string, a picture color, and a picture resolution;
    且所述字符串选择模块中,所述字符串的长度在所述最小允许长度和最大允许长度之间随机确定;And in the string selection module, the length of the character string is randomly determined between the minimum allowable length and the maximum allowable length;
    且所述图片预生成模块中,所述图片根据所述验证码参数所包括的图片颜色和图片分辨率确定。 And in the picture pre-generation module, the picture is determined according to a picture color and a picture resolution included in the verification code parameter.
  8. 根据权利要求6所述的图片验证码生成系统,其中,所述扭曲处理包括:在每个所述渲染字符上选择至少一个部位作为待扭曲部位,在每个所述待扭曲部位进行向上平移、向下平移、向左平移或向右平移。The picture verification code generating system according to claim 6, wherein the distortion processing comprises: selecting at least one portion as a to-be-distorted portion on each of the rendered characters, and performing an upward shift on each of the to-be-distorted portions, Pan down, pan left, or pan right.
  9. 根据权利要求6所述的图片验证码生成系统,其中,每条所述干扰线采用如下方式生成:The picture verification code generating system according to claim 6, wherein each of said interference lines is generated in the following manner:
    在所述图片上随机选择多个轨迹点,生成包括所有所述轨迹点的多次方程轨迹。A plurality of track points are randomly selected on the picture to generate a plurality of equation tracks including all of the track points.
  10. 根据权利要求6所述的图片验证码生成系统,其中,所述干扰线与所述字符的颜色相同,且所述干扰线的粗细所有所述扭曲字符的最大宽度和最小宽度之间渐变。 The picture verification code generating system according to claim 6, wherein the interference line is the same as the color of the character, and the thickness of the interference line is gradually changed between a maximum width and a minimum width of all the twisted characters.
PCT/CN2016/070553 2015-02-05 2016-01-11 Image verification code generation method and system WO2016124066A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510060897.1 2015-02-05
CN201510060897.1A CN104700441B (en) 2015-02-05 2015-02-05 A kind of method for generating picture verification codes and system

Publications (1)

Publication Number Publication Date
WO2016124066A1 true WO2016124066A1 (en) 2016-08-11

Family

ID=53347523

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/070553 WO2016124066A1 (en) 2015-02-05 2016-01-11 Image verification code generation method and system

Country Status (3)

Country Link
CN (1) CN104700441B (en)
HK (1) HK1208951A1 (en)
WO (1) WO2016124066A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106650398A (en) * 2017-01-03 2017-05-10 深圳博十强志科技有限公司 Recognition system and recognition method for verification code of mobile platform
CN106778199A (en) * 2016-11-29 2017-05-31 深圳中兴网信科技有限公司 The processing method and processing unit of picture validation code
CN110246198A (en) * 2019-05-21 2019-09-17 北京奇艺世纪科技有限公司 Word selection verification code generation method, device, electronic equipment and storage medium
CN110866238A (en) * 2019-11-13 2020-03-06 北京工业大学 Generation method of verification code image based on countermeasure sample
CN111259365A (en) * 2020-01-10 2020-06-09 河北先见软件科技股份有限公司 Dynamic verification code generation method
CN111953647A (en) * 2020-06-22 2020-11-17 北京百度网讯科技有限公司 Security verification method and device, electronic equipment and storage medium

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104700441B (en) * 2015-02-05 2018-03-30 北京京东尚科信息技术有限公司 A kind of method for generating picture verification codes and system
CN106295306B (en) * 2016-08-15 2019-02-01 长春工程学院 A kind of generation method of picture validation code
CN107103225A (en) * 2017-03-28 2017-08-29 成都优易数据有限公司 A kind of method for generating graphical verification code
CN109598270B (en) * 2018-12-04 2020-05-05 龙马智芯(珠海横琴)科技有限公司 Method and device for identifying distorted characters, storage medium and processor
CN112073359B (en) * 2019-06-11 2023-01-24 腾讯科技(深圳)有限公司 Information interaction method, device, equipment and system
CN111079119B (en) * 2019-12-04 2022-04-22 北京达佳互联信息技术有限公司 Verification method, device, equipment and storage medium
CN113821786B (en) * 2020-06-18 2024-05-10 中移(苏州)软件技术有限公司 Verification code obtaining and displaying method and related device
CN116186674A (en) * 2023-02-21 2023-05-30 宿迁乐享知途网络科技有限公司 High-contrast man-machine interaction verification method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298763A (en) * 2010-06-28 2011-12-28 腾讯科技(北京)有限公司 Method and system for generating picture identifying code
CN102663672A (en) * 2012-05-03 2012-09-12 杭州朗和科技有限公司 Picture verification code generation method and device
CN103179092A (en) * 2011-12-22 2013-06-26 阿里巴巴集团控股有限公司 Method, system and device for providing verification code information
CN104700441A (en) * 2015-02-05 2015-06-10 北京京东尚科信息技术有限公司 Image verification code generating method and image verification code generating system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4266784B2 (en) * 2003-11-14 2009-05-20 キヤノン株式会社 Image processing system and image processing method
CN103731403B (en) * 2012-10-12 2017-06-23 阿里巴巴集团控股有限公司 A kind of identifying code generates system and method
CN104065666B (en) * 2014-07-03 2017-08-01 北京齐尔布莱特科技有限公司 A kind of method and device for generating picture validation code

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298763A (en) * 2010-06-28 2011-12-28 腾讯科技(北京)有限公司 Method and system for generating picture identifying code
CN103179092A (en) * 2011-12-22 2013-06-26 阿里巴巴集团控股有限公司 Method, system and device for providing verification code information
CN102663672A (en) * 2012-05-03 2012-09-12 杭州朗和科技有限公司 Picture verification code generation method and device
CN104700441A (en) * 2015-02-05 2015-06-10 北京京东尚科信息技术有限公司 Image verification code generating method and image verification code generating system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106778199A (en) * 2016-11-29 2017-05-31 深圳中兴网信科技有限公司 The processing method and processing unit of picture validation code
CN106650398A (en) * 2017-01-03 2017-05-10 深圳博十强志科技有限公司 Recognition system and recognition method for verification code of mobile platform
CN106650398B (en) * 2017-01-03 2023-04-14 深圳博十强志科技有限公司 Verification code identification system and identification method of mobile platform
CN110246198A (en) * 2019-05-21 2019-09-17 北京奇艺世纪科技有限公司 Word selection verification code generation method, device, electronic equipment and storage medium
CN110246198B (en) * 2019-05-21 2023-05-02 北京奇艺世纪科技有限公司 Method and device for generating character selection verification code, electronic equipment and storage medium
CN110866238A (en) * 2019-11-13 2020-03-06 北京工业大学 Generation method of verification code image based on countermeasure sample
CN110866238B (en) * 2019-11-13 2023-04-21 北京工业大学 Verification code image generation method based on countermeasure sample
CN111259365A (en) * 2020-01-10 2020-06-09 河北先见软件科技股份有限公司 Dynamic verification code generation method
CN111953647A (en) * 2020-06-22 2020-11-17 北京百度网讯科技有限公司 Security verification method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
HK1208951A1 (en) 2016-03-18
CN104700441B (en) 2018-03-30
CN104700441A (en) 2015-06-10

Similar Documents

Publication Publication Date Title
WO2016124066A1 (en) Image verification code generation method and system
US8881251B1 (en) Electronic authentication using pictures and images
El Ahmad et al. CAPTCHA design: Color, usability, and security
TWI606715B (en) Authentication code forming system and method
WO2016169437A1 (en) Verification picture generation method and device, and server
CN108351961A (en) Image and characteristic mass merge ocular angiogenesis and face and/or sub- facial information for the image enhancement and feature extraction of ocular angiogenesis and face recognition and for biological recognition system
JP6433508B2 (en) Method and system for generating verification code
CN109684469A (en) Filtering sensitive words method, apparatus, computer equipment and storage medium
WO2019184122A1 (en) Login verification method and apparatus, terminal device and storage medium
CN109660327A (en) Block chain encryption method, device and readable storage medium storing program for executing based on iris
CN104065666B (en) A kind of method and device for generating picture validation code
CN110246198B (en) Method and device for generating character selection verification code, electronic equipment and storage medium
CN103927465A (en) Verification code generating and verifying method based on graphs
US20190141028A1 (en) System and Methods for Authentication and/or Identification
CN104618350A (en) Generation method of image checking code
CN109215437A (en) A kind of drills to improve one's handwriting system and method
CN108304839A (en) A kind of image processing method and device
CN103514393A (en) Method for achieving three-dimensional verification code
CN110610180A (en) Method, device and equipment for generating recognition set of wrongly-recognized words and storage medium
KR102273093B1 (en) Method of inputting confidential data on a terminal
CN109977649A (en) Method for generating picture verification codes, device, storage medium and computer equipment
US20150036871A1 (en) Methods and apparatuses for embedding digital watermark into and extracting digital watermark from text
CN106250755B (en) Method and device for generating verification code
US9614838B1 (en) Taking a picture of a one-time use passcode and using the picture to authenticate
Sahu et al. Survey on various techniques of user authentication and graphical password

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16746061

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 06/12/2017)

122 Ep: pct application non-entry in european phase

Ref document number: 16746061

Country of ref document: EP

Kind code of ref document: A1