CN110677239B - Verification code generation method and device - Google Patents

Verification code generation method and device Download PDF

Info

Publication number
CN110677239B
CN110677239B CN201910788699.5A CN201910788699A CN110677239B CN 110677239 B CN110677239 B CN 110677239B CN 201910788699 A CN201910788699 A CN 201910788699A CN 110677239 B CN110677239 B CN 110677239B
Authority
CN
China
Prior art keywords
character
code
characters
verification
verification code
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201910788699.5A
Other languages
Chinese (zh)
Other versions
CN110677239A (en
Inventor
赖宇航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Gongjin Electronics Co Ltd
Original Assignee
Shenzhen Gongjin Electronics Co Ltd
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 Shenzhen Gongjin Electronics Co Ltd filed Critical Shenzhen Gongjin Electronics Co Ltd
Priority to CN201910788699.5A priority Critical patent/CN110677239B/en
Publication of CN110677239A publication Critical patent/CN110677239A/en
Application granted granted Critical
Publication of CN110677239B publication Critical patent/CN110677239B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0863Generation of secret information including derivation or calculation of cryptographic keys or passwords involving passwords or one-time passwords
    • 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
    • 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/45Structures or tools for the administration of authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0815Network architectures or network communication protocols for network security for authentication of entities providing single-sign-on or federations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/083Network architectures or network communication protocols for network security for authentication of entities using passwords
    • H04L63/0838Network architectures or network communication protocols for network security for authentication of entities using passwords using one-time-passwords

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

The application is applicable to the technical field of computer application, and provides a verification code generation method and a verification code generation device, wherein the verification code generation method comprises the following steps: by generating a sequence of characters; the character sequence consists of letters and numbers; extracting code seeds corresponding to characters in the character sequence from a preset code seed library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix consisting of characters, forming an image which can be recognized by human eyes and consists of the characters by the characters with contrast in the character matrix, meeting the requirements of being recognizable by human beings but difficult to recognize mechanically by the display mode of the image, meeting the use requirements of a character terminal and improving the safety of verification code verification in the character terminal.

Description

Verification code generation method and device
Technical Field
The application belongs to the technical field of computer application, and particularly relates to a verification code generation method and device.
Background
The traditional verification code technology based on pictures is widely applied to the environments with picture display capability, such as the login of web pages and application programs, user verification and the like, and is a mature method capable of preventing mechanical brute force from cracking and enhancing the security of weak passwords. However, in the terminal environment where only characters can be displayed under the environments of serial ports, remote terminal protocols, secure shell protocols and the like, the method for displaying the verification code through the picture is useless, but in many devices with limited resources, the character terminal is the only remote interaction mode, for example, on the character terminal of a bank, links such as login and verification can be realized only through the character verification mode. Therefore, the verification method in the prior art cannot meet the use requirement of the character terminal in practical application, and has the problem of large limitation.
Disclosure of Invention
The embodiment of the application provides a verification code generation method and device, and can solve the problems that in the prior art, a verification mode cannot meet the use requirements of a character terminal in practical application, and the limitation is large.
In a first aspect, an embodiment of the present application provides a verification code generation method, including:
generating a character sequence; the character sequence consists of letters and numbers;
extracting code seeds corresponding to characters in the character sequence from a preset code seed library;
and deforming and combining the code seeds to obtain the verification code.
Wherein the generating the character sequence comprises:
setting a character space of the verification code;
calculating the total number of characters which can be accommodated in the character space;
and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
The character space comprises a character line number and a character number capable of being accommodated in each line; the calculating the total number of characters that can be accommodated in the character space includes:
and calculating the total number of the characters according to the number of the character lines and the number of the characters of each line.
After the generating the character sequence, the method further includes:
identifying a preset first character in the character sequence; the first character represents a confusable character;
and removing the first character from the character sequence.
Wherein, the transforming and combining the code seeds to obtain the verification code comprises:
deforming the code seed; the deformation comprises stretching and/or rotation;
combining the deformed code seeds;
filling the combined code seeds into a preset character space;
filling a blank area in the character space with a preset background character;
and replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
Wherein, the combining the deformed code seeds comprises:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
Wherein, after the code seeds are deformed and combined to obtain the verification code, the method further comprises:
converting the verification code into a character array;
sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
In a second aspect, an embodiment of the present application provides an apparatus for generating a verification code, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:
generating a character sequence; the character sequence consists of letters and numbers;
extracting code types corresponding to the characters in the character sequence from a preset code type library;
and deforming and combining the code seeds to obtain the verification code.
Wherein the generating the character sequence comprises:
setting a character space of the verification code;
calculating the total number of characters which can be accommodated in the character space;
and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
The character space comprises a character line number and a character number capable of being accommodated in each line; the calculating the total number of characters that can be accommodated in the character space includes:
and calculating the total number of the characters according to the number of the character lines and the number of the characters in each line.
After the generating the character sequence, the method further includes:
identifying a preset first character in the character sequence; the first character represents a character susceptible to confusion;
and eliminating the first character from the character sequence.
Wherein, the transforming and combining the code seeds to obtain the verification code comprises:
deforming the code seed; the deformation comprises stretching and/or rotation;
combining the deformed code seeds;
filling the combined code seeds into a preset character space;
filling a blank area in the character space with a preset background character;
and replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
Wherein, the combining the deformed code seeds comprises:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
Wherein, after the code seeds are deformed and combined to obtain the verification code, the method further comprises:
converting the verification code into a character array;
sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
In a third aspect, an embodiment of the present application provides an apparatus for generating a verification code, including:
a generating unit configured to generate a character sequence; the character sequence consists of letters and numbers;
the extraction unit is used for extracting the code seed corresponding to the character in the character sequence from a preset code seed library;
and the combination unit is used for deforming and combining the code seeds to obtain the verification code.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program comprising program instructions that, when executed by a processor, cause the processor to perform the method of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to execute the verification code generation method described in any one of the above first aspects.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Compared with the prior art, the embodiment of the application has the advantages that: by generating a sequence of characters; the character sequence consists of letters and numbers; extracting code types corresponding to the characters in the character sequence from a preset code type library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix formed by characters, forming an image which can be recognized by human eyes and is formed by the characters with contrast in the character matrix, meeting the requirements of being recognized by human beings but difficult to recognize mechanically through the display mode of the image, meeting the use requirements of a character terminal and also improving the safety of verification code verification in the character terminal.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of a verification code generation method according to an embodiment of the present application;
fig. 2 is a schematic diagram of code types provided in this embodiment;
FIG. 3 is a flowchart of a verification code generation method according to a second embodiment of the present application;
fig. 4 is a schematic diagram of a code type modification provided in this embodiment;
FIG. 5 is a schematic diagram of a verification process provided in this embodiment;
fig. 6 is a schematic diagram of an authentication code generation apparatus according to a third embodiment of the present application;
fig. 7 is a schematic diagram of an authentication code generation apparatus according to a fourth embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing a relative importance or importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Referring to fig. 1, fig. 1 is a flowchart of a verification code generation method according to an embodiment of the present application. The execution subject of the verification code generation method in this embodiment is a device with a verification code generation function, including but not limited to a computer, a server, a tablet computer, or a terminal. The verification code generation method as shown in the figure can comprise the following steps:
s101: generating a character sequence; the character sequence is composed of letters and numbers.
The traditional verification code technology based on pictures is widely applied to the environments with picture display capability, such as webpage login, application program login and the like, and is a mature method capable of preventing mechanical brute force from cracking and enhancing the security of weak passwords. However, in a terminal environment where only characters can be displayed, such as a serial port, a remote terminal protocol, a secure shell protocol and the like, the method for displaying the verification code through the picture is useless, but in a plurality of devices with limited resources, the character terminal is the only remote interaction mode, and the traditional solution is to limit the number of wrong attempts within a period of time, but has no reinforcing effect on the security of weak passwords. Aiming at the situation, the invention provides the verification code which can be displayed on the character terminal.
Note that the character terminal in this embodiment is used to indicate a terminal that implements a data processing function by using a command line statement, for example, a transaction terminal of a bank, a storage terminal of a supermarket, and the like, and is not limited herein.
In this embodiment, a character space of the verification code is set first, and the character space of this embodiment is specified by the number of characters in each line and the number of lines of characters. Wherein, the number of characters in each line must not exceed the number of characters that can be displayed in one line of the terminal; and the number of the character lines is not less than the preset number and/or cannot exceed the maximum number of the lines which can be displayed by the terminal at one time. Through the character space of the verification code, the length of the supportable verification code can be calculated, and a deformation mode and a combination mode can be carried out. The character sequence in this embodiment is a random character string composed of letters and numbers, and the length is specified comprehensively by an algorithm according to the size of the character space of the verification code and the verification difficulty, which is the basis for generating the verification code array.
S102: and extracting the code seed corresponding to the character in the character sequence from a preset code seed library.
The background characters in the present embodiment are used to represent characters in the code as the background; the indicator in the present embodiment is used to indicate a character constituting a character recognizable to the human eye in the code. The code seed in the embodiment is the basis for generating the character verification code, and 1-9, A-Z character groups which can be recognized by human eyes are presented through the specific arrangement of the background characters and the display characters, which is the basis for the deformation and combination of the later verification code. For example, referring to fig. 2 together, fig. 2 is a code type diagram provided in the present embodiment, three code types from left to right are 1 to 3 respectively, where "-" is a background character and "0" is a display symbol.
In this embodiment, a code seed library is preset and used for selecting the verification code seed from the code seed library. The specific selection mode is that according to the generated character sequence and the characters in the character sequence, the code seeds corresponding to the characters in the sequence are extracted from the code seed library.
S103: and deforming and combining the code seeds to obtain the verification code.
After the code seeds are extracted, the code seeds are deformed and combined. The code deformation is based on the requirement of complexity, and the extracted code is subjected to transformation such as stretching and rotation, so as to increase the complexity of the verification code. The code merging is to fill the deformed code into the character space of the verification code according to a certain combination mode and fill the blank place with the background character.
And after the verification code is obtained, converting the verification code in the character space of the verification code into a verification code array, and returning the verification code array and the corresponding character sequence to the terminal program for the terminal program to use.
According to the scheme, a character sequence is generated; the character sequence consists of letters and numbers; extracting code types corresponding to the characters in the character sequence from a preset code type library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix consisting of characters, forming an image which can be recognized by human eyes and consists of the characters by the characters with contrast in the character matrix, meeting the requirements of being recognizable by human beings but difficult to recognize mechanically by the display mode of the image, meeting the use requirements of a character terminal and improving the safety of verification code verification in the character terminal.
Referring to fig. 3, fig. 3 is a flowchart of a verification code generation method according to an embodiment of the present application. The execution subject of the verification code generation method in this embodiment is a device with a verification code generation function, including but not limited to a computer, a server, a tablet computer, or a terminal. The verification code generation method as shown in the figure can comprise the following steps:
s301: generating a character sequence; the character sequence is composed of letters and numbers.
The character sequence in the embodiment is a random character string composed of letters and numbers, and the length is comprehensively specified by an algorithm according to the size of the character space of the verification code and the verification difficulty, and is the basis for generating the verification code array.
Further, step S301 includes:
s3011: and setting the character space of the verification code.
In this embodiment, a verification code character space is set first, and the character space of this embodiment is specified by the number of characters per line and the number of lines of characters. Wherein, the number of characters in each line must not exceed the number of characters that can be displayed in one line of the terminal; and the number of the character lines is not less than the preset number and/or cannot exceed the maximum number of lines which can be displayed at one time by the terminal. Through the character space of the verification code, the length of the supportable verification code can be calculated, and a deformation mode and a combination mode can be carried out.
S3012: and calculating the total number of characters which can be accommodated in the character space.
In this embodiment, the number of characters in each line is used to indicate the number of characters that can be displayed in one line of the terminal, the number of character lines is used to indicate the total number of character lines that can be displayed in the character space, and the total number of characters is calculated according to the number of character lines and the number of characters in each line. The specific calculation method may be that the number of the character lines is multiplied by the number of the characters in each line to obtain the total number of the characters.
S3013: and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
The character sequence is generated according to the total number of the characters, the character sequence in the embodiment is used for representing a string of random character strings consisting of letters and numbers, the length is comprehensively specified by an algorithm according to the size of a character space of the verification code and the verification difficulty, and the method is the basis for generating the verification code array.
Further, after step S301, the method further includes:
identifying a preset first character in the character sequence; the first character represents a character susceptible to confusion;
and removing the first character from the character sequence.
Specifically, the first character in the present embodiment represents a character which is easily confused, and similar characters which may cause misunderstanding, i.e., the first character, such as the numeral 0 and the capital letter O, the numeral 2 and the letter Z, are excluded from the valid characters and numerals.
S302: and extracting the code seed corresponding to the character in the character sequence from a preset code seed library.
In this embodiment, the implementation manner of S302 is completely the same as that of S102 in the embodiment corresponding to fig. 1, and reference may be specifically made to the related description of S102 in the embodiment corresponding to fig. 1, which is not repeated herein.
S303: and deforming and combining the code seeds to obtain the verification code.
And after the code seeds are obtained, deforming and combining the code seeds to obtain the verification code. The verification code is prevented from being identified by a machine, and the safety of the verification code is improved.
Further, step S303 includes:
s3031: deforming the code seed; the deformation comprises stretching and/or rotation.
After the code seeds are extracted, the code seeds are deformed and combined. The code type deformation is based on the requirement of complexity, and the extracted code type is subjected to transformation such as stretching and rotation, so that the complexity of the verification code is increased.
Referring to fig. 4, fig. 4 is a schematic diagram of a code type deformation provided in the present embodiment, in which a code type with a number "1" is sequentially reduced, stretched, rotated by 45 degrees, rotated by 90 degrees, and rotated by 180 degrees, respectively, in the present embodiment, the principle of memorable stretching and/or rotation is to reduce the recognition degree of machine recognition, and human recognition is not affected, and the complexity of the verification code is increased by stretching and/or rotating.
S3032: and combining the code seeds after the deformation.
Further, step S3032 includes:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
Specifically, the code merging means that the deformed code is combined according to a certain combination mode, and the basic combination mode includes, but is not limited to, left-right arrangement, staggered arrangement, overlapping arrangement and the like according to the size of the verification code space. The left-right arrangement is used for indicating that the characters are arranged in a straight line according to the sequence from left to right or from right to left. The offset arrangement is used to indicate that partial characters are offset in the horizontal direction on the basis of the left-right arrangement. The overlapping arrangement is used for indicating that on the basis of the dislocation arrangement, the displays of the verification codes are partially overlapped on the premise of not influencing human recognition, so that the difficulty of automatic program recognition is increased.
S3033: and filling the code seeds after combination into a preset character space.
And after combining the deformed code seeds, filling the code seeds obtained by combination into a verification code character space.
S3034: and filling a blank area in the character space with a preset background character.
And after filling the code seed obtained by combination into the character space of the verification code, filling a blank area in the character space with a preset background character. The background character in the present embodiment is used to indicate a character as a background in the code, and for example, the background character in the present embodiment may be "-".
S3035: and replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
The interference code in this embodiment is a group of special character pairs with visual contrast, for example: the mark, the @, the 'M' and the like are used for replacing background characters and display symbols of the code, and the diversity of display of the verification code is increased. And replacing the display character and the background character in the character space of the combined verification code with the interference code, thereby increasing the diversity of the verification code.
S304: and converting the verification code into a character array.
The character sequence in this embodiment is used to represent a string of random characters consisting of letters and numbers. The verification code array in this embodiment, corresponding to the character sequence, is a two-dimensional character array generated by the character sequence through a specific process, and the terminal can display a verification code image by displaying the array on the terminal in a row-column manner.
After the verification code is generated, the verification code is converted into a two-dimensional character array, the two-dimensional character array is generated through a specific process by the character sequence, and the terminal can display a verification code image by displaying the array on the terminal in a row-column mode.
S305: sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
After the character array is generated, the character array and the character sequence are sent to a preset terminal, so that the terminal is triggered to display the verification code image formed by the character array. It should be noted that the character sequence of the present embodiment is used for comparing with the characters input by the user to obtain the verification result.
Referring to fig. 5, fig. 5 is a schematic diagram of a verification process provided in the present embodiment. The difference from the prior art is that the verification code of the embodiment is completely independent of the user password, is not easily identified by a program, is different every time, and can effectively make up for the short board of the weak password. The specific verification process comprises the steps of firstly establishing connection between a verification terminal and a server, requesting a check code when verification attempt can be carried out or verification can be carried out continuously, obtaining a verification code array and a verification code sequence (namely a character sequence), displaying the verification code according to the verification code array to prompt a user to input the check code, determining whether the verification code is matched with the verification code sequence according to the check code, if so, successfully verifying, enabling the user to carry out next-step login, and if not, trying verification again. When the user logs in, the user name and the password are input and verified, and the successful login is prompted after the verification is passed.
According to the scheme, a character sequence is generated; the character sequence consists of letters and numbers; extracting code types corresponding to the characters in the character sequence from a preset code type library; deforming and combining the code seeds to obtain a verification code, and converting the verification code into a character array; sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix consisting of characters, forming an image which can be recognized by human eyes and consists of the characters by the characters with contrast in the character matrix, meeting the requirements of being recognizable by human beings but difficult to recognize mechanically by the display mode of the image, meeting the use requirements of a character terminal and improving the safety of verification code verification in the character terminal.
Referring to fig. 6, fig. 6 is a schematic diagram of an identifying code generating apparatus according to a third embodiment of the present application. The verification code generation apparatus 600 may be a mobile terminal such as a smart phone or a tablet computer. The verification code generating apparatus 600 of the present embodiment includes units for performing steps in the embodiment corresponding to fig. 1, please refer to fig. 1 and the related description in the embodiment corresponding to fig. 1, which are not repeated herein. The verification code generation apparatus 600 of the present embodiment includes:
a generating unit 601 configured to generate a character sequence; the character sequence consists of letters and numbers;
an extracting unit 602, configured to extract a code seed corresponding to a character in the character sequence from a preset code seed library;
and a combining unit 603, configured to deform and combine the code seeds to obtain the verification code.
Further, the generating unit 601 includes:
the space unit is used for setting a character space of the verification code;
the computing unit is used for computing the total number of the characters which can be contained in the character space;
and the sequence unit is used for generating a character sequence according to the total number of the characters, and the number of the characters contained in the character sequence is the same as the total number of the characters.
Further, the character space comprises the number of character lines and the number of characters capable of being accommodated in each line; the calculation unit includes:
and the total number calculating unit is used for calculating the total number of the characters according to the number of the character lines and the number of the characters in each line.
Further, the verification code generating apparatus 600 further includes:
the identification unit is used for identifying a first character preset in the character sequence; the first character represents a character susceptible to confusion;
and the removing unit is used for removing the first character from the character sequence.
Further, the combining unit 603 includes:
the deformation unit is used for deforming the code seeds; the deformation comprises stretching and/or rotation;
a code combining unit for combining the deformed code seeds;
the first filling unit is used for filling the code seeds after combination into a preset character space;
the second filling unit is used for filling a blank area in the character space with a preset background character;
and the replacing unit is used for replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
Further, the method comprises the following steps:
and the code combination unit is used for combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapping arrangement mode.
Further, the method comprises the following steps:
the conversion unit is used for converting the verification code into a character array;
the sending unit is used for sending the character array and the character sequence to a preset terminal and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
According to the scheme, a character sequence is generated; the character sequence consists of letters and numbers; extracting code types corresponding to the characters in the character sequence from a preset code type library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix consisting of characters, forming an image which can be recognized by human eyes and consists of the characters by the characters with contrast in the character matrix, meeting the requirements of being recognizable by human beings but difficult to recognize mechanically by the display mode of the image, meeting the use requirements of a character terminal and improving the safety of verification code verification in the character terminal.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Referring to fig. 7, fig. 7 is a schematic diagram of an identifying code generating apparatus according to a fourth embodiment of the present application. The verification code generation apparatus 700 in the present embodiment shown in fig. 7 may include: a processor 701, a memory 702, and a computer program 703 stored in the memory 702 and executable on the processor 701. The processor 701 implements the steps in the above-described respective verification code generation method embodiments when executing the computer program 703. The memory 702 is used to store a computer program comprising program instructions. The processor 701 is configured to execute program instructions stored by the memory 702. Wherein the processor 701 is configured to invoke the program instructions to perform the following operations:
the processor 701 is configured to:
generating a character sequence; the character sequence consists of letters and numbers;
extracting code seeds corresponding to characters in the character sequence from a preset code seed library;
and deforming and combining the code seeds to obtain the verification code.
Further, the processor 701 is specifically configured to:
setting a character space of the verification code;
calculating the total number of characters which can be accommodated in the character space;
and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
Further, the processor 701 is specifically configured to:
and calculating the total number of the characters according to the number of the character lines and the number of the characters in each line.
Further, the processor 701 is specifically configured to:
identifying a preset first character in the character sequence; the first character represents a confusable character;
and removing the first character from the character sequence.
Further, the processor 701 is specifically configured to:
deforming the code seed; the deformation comprises stretching and/or rotation;
combining the deformed code seeds;
filling the combined code seeds into a preset character space;
filling a blank area in the character space with a preset background character;
and replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
Further, the processor 701 is specifically configured to:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
Further, the processor 701 is specifically configured to:
converting the verification code into a character array;
sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
According to the scheme, a character sequence is generated; the character sequence consists of letters and numbers; extracting code types corresponding to the characters in the character sequence from a preset code type library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix consisting of characters, forming an image which can be recognized by human eyes and consists of the characters by the characters with contrast in the character matrix, meeting the requirements of being recognizable by human beings but difficult to recognize mechanically by the display mode of the image, meeting the use requirements of a character terminal and improving the safety of verification code verification in the character terminal.
It should be understood that, in the embodiment of the present Application, the Processor 701 may be a Central Processing Unit (CPU), and the Processor may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 702 may include both read-only memory and random access memory, and provides instructions and data to the processor 701. A portion of the memory 702 may also include non-volatile random access memory. For example, the memory 702 may also store device type information.
In a specific implementation, the processor 701, the memory 702, and the computer program 703 described in this embodiment may execute the implementation manners described in the first embodiment and the second embodiment of the verification code generation method provided in this embodiment, and may also execute the implementation manners of the terminal described in this embodiment, which is not described herein again.
In another embodiment of the present application, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program comprising program instructions that when executed by a processor implement:
generating a character sequence; the character sequence consists of letters and numbers;
extracting code types corresponding to the characters in the character sequence from a preset code type library;
and deforming and combining the code seeds to obtain the verification code.
Further, the computer program when executed by the processor further implements:
setting a character space of the verification code;
calculating the total number of characters which can be accommodated in the character space;
and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
Further, the computer program when executed by the processor further implements:
and calculating the total number of the characters according to the number of the character lines and the number of the characters in each line.
Further, the computer program when executed by the processor further implements:
identifying a preset first character in the character sequence; the first character represents a confusable character;
and removing the first character from the character sequence.
Further, the computer program when executed by the processor further implements:
deforming the code seed; the deformation comprises stretching and/or rotation;
combining the deformed code seeds;
filling the combined code seeds into a preset character space;
filling a blank area in the character space with a preset background character;
and replacing the background characters in the character space and the characters in the code seeds by preset interference characters.
Further, the computer program when executed by the processor further implements:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
Further, the computer program when executed by the processor further implements:
converting the verification code into a character array;
sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
According to the scheme, a character sequence is generated; the character sequence consists of letters and numbers; extracting code seeds corresponding to characters in the character sequence from a preset code seed library; and deforming and combining the code seeds to obtain the verification code. The method comprises the steps of determining code types corresponding to a character sequence, deforming and combining the code types to obtain a verification code, finally generating a character matrix formed by characters, forming an image which can be recognized by human eyes and is formed by the characters with contrast in the character matrix, meeting the requirements of being recognized by human beings but difficult to recognize mechanically through the display mode of the image, meeting the use requirements of a character terminal and also improving the safety of verification code verification in the character terminal.
The computer readable storage medium may be an internal storage unit of the terminal according to any of the foregoing embodiments, for example, a hard disk or a memory of the terminal. The computer readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the terminal. The computer-readable storage medium is used for storing the computer program and other programs and data required by the terminal. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the terminal and the unit described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed terminal and method can be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may also be an electric, mechanical or other form of connection.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present application. In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially or partially contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (9)

1. A verification code generation method, comprising:
generating a character sequence; the character sequence consists of letters and numbers;
extracting code types corresponding to the characters in the character sequence from a preset code type library;
deforming and combining the code seeds to obtain the verification code, which specifically comprises the following steps: deforming the code seed; the method comprises the steps of deforming, stretching and/or rotating, combining deformed code seeds, filling the combined code seeds into a preset verification code character space, filling a blank area in the character space with preset background characters, replacing the background characters in the character space and the characters in the code seeds with preset interference characters, wherein the code seeds are a basis for generating character verification codes, and a character group which can be recognized by human eyes is presented by specific arrangement of the background characters and display characters.
2. The captcha generation method of claim 1, wherein the generating a sequence of characters comprises:
setting a character space of the verification code;
calculating the total number of characters which can be accommodated in the character space;
and generating a character sequence according to the total number of the characters, wherein the number of the characters contained in the character sequence is the same as the total number of the characters.
3. The captcha generation method of claim 2, wherein the character space includes a number of rows of characters and a number of characters that can be accommodated by each row; the calculating the total number of characters that can be accommodated in the character space includes:
and calculating the total number of the characters according to the number of the character lines and the number of the characters of each line.
4. The captcha generating method of claim 1, wherein after generating the sequence of characters, further comprising:
identifying a preset first character in the character sequence; the first character represents a confusable character;
and removing the first character from the character sequence.
5. The captcha generating method of claim 1, wherein said combining the deformed code seeds comprises:
and combining the deformed code seeds in a left-right arrangement mode, a staggered arrangement mode and/or an overlapped arrangement mode.
6. The verification code generation method of any one of claims 1 to 5, wherein after the transforming and combining the code seeds to obtain the verification code, further comprising:
converting the verification code into a character array;
sending the character array and the character sequence to a preset terminal, and triggering the terminal to display a verification code image formed by the character array; and the character sequence is used for comparing with the characters input by the user to obtain a verification result.
7. An authentication code generation apparatus, comprising:
a generating unit configured to generate a character sequence; the character sequence consists of letters and numbers;
the extraction unit is used for extracting the code seed corresponding to the character in the character sequence from a preset code seed library;
the combination unit is used for deforming and combining the code seeds to obtain verification codes;
wherein the combining unit includes: the deformation unit is used for deforming the code seeds; the deformation comprises stretching and/or rotation;
a code combining unit for combining the deformed code seeds;
the first filling unit is used for filling the combined code seeds into a preset verification code character space;
the second filling unit is used for filling a blank area in the character space with a preset background character;
the replacing unit is used for replacing the background characters in the character space and the characters in the code types by preset interference characters;
the code seed is the basis for generating the character verification code, and a character group which can be recognized by human eyes is presented by the specific arrangement of the background characters and the display characters.
8. An authentication code generation apparatus comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN201910788699.5A 2019-08-26 2019-08-26 Verification code generation method and device Active CN110677239B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910788699.5A CN110677239B (en) 2019-08-26 2019-08-26 Verification code generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910788699.5A CN110677239B (en) 2019-08-26 2019-08-26 Verification code generation method and device

Publications (2)

Publication Number Publication Date
CN110677239A CN110677239A (en) 2020-01-10
CN110677239B true CN110677239B (en) 2022-09-06

Family

ID=69075782

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910788699.5A Active CN110677239B (en) 2019-08-26 2019-08-26 Verification code generation method and device

Country Status (1)

Country Link
CN (1) CN110677239B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111667549B (en) * 2020-04-28 2023-04-07 华东师范大学 Method, device and storage medium for generating graphic verification code based on countermeasure sample and random transformation
CN113240471B (en) * 2021-05-19 2024-10-15 完美世界(北京)软件科技发展有限公司 Method and device for generating prize-exchanging code, electronic equipment and storage medium
CN113158171A (en) * 2021-05-26 2021-07-23 成都优信创展信息技术有限公司 Verification code generation method, verification code authentication method, electronic device, and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106803904A (en) * 2016-11-24 2017-06-06 德为显示科技股份有限公司 A kind of liquid crystal display OSD display methods and system
CN107241327A (en) * 2017-06-06 2017-10-10 北京洋浦伟业科技发展有限公司 The checking code verification method and device of detection are rotated based on character

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102768754B (en) * 2012-08-03 2014-07-09 网易(杭州)网络有限公司 Method and device for implementation of picture verification code
CN106899411B (en) * 2016-12-08 2021-09-21 创新先进技术有限公司 Verification method and device based on verification code

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106803904A (en) * 2016-11-24 2017-06-06 德为显示科技股份有限公司 A kind of liquid crystal display OSD display methods and system
CN107241327A (en) * 2017-06-06 2017-10-10 北京洋浦伟业科技发展有限公司 The checking code verification method and device of detection are rotated based on character

Also Published As

Publication number Publication date
CN110677239A (en) 2020-01-10

Similar Documents

Publication Publication Date Title
US11936647B2 (en) Identity verification method and apparatus, storage medium, and computer device
US10218506B1 (en) Cross-device authentication
CN110677239B (en) Verification code generation method and device
US9117065B2 (en) Dynamic interactive identity authentication method and system
CN108229956A (en) Network bank business method, apparatus, system and mobile terminal
EP3203681B1 (en) Sequential biometric cryptosystem and sequential biometric cryptographic processing method
US20130047237A1 (en) Password security input system using shift value of password key and password security input method thereof
CN104657639B (en) A kind of method of testing and system of operating system identity authentication scheme
US20230262057A1 (en) Systems and methods for authenticating users within a computing or access control environment
CN104408341A (en) Smart phone user identity authentication method based on gyroscope behavior characteristics
Mali et al. Advanced pin entry method by resisting shoulder surfing attacks
CN104657653B (en) The verification method and checking device of image authentication code
US20210365539A1 (en) Visual Image Authentication
US11128453B2 (en) Visual image authentication
CN106651372A (en) Data processing method and system
CN110990811A (en) Identity authentication method and device
CN107368722A (en) Verification method, computer-readable recording medium, the mobile terminal of biometric image
CN113988242A (en) Multi-region-based anti-counterfeiting code generation and verification method, system, equipment and medium
CN110111477B (en) Lottery information anti-counterfeiting authentication method and system based on information hiding
WO2015062441A1 (en) Cgi web interface multi-session verification code generation and verification method
CN113255505A (en) Certificate photo generation method, device, equipment and storage medium
CN106778214A (en) Fingerprint verification method and system
CN107844696B (en) Verification code interference method and server
CN111340484A (en) Payment verification method, device, system, storage medium and computer equipment
CN113935008A (en) User authentication method, device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant