CN110677239A - Verification code generation method and device - Google Patents

Verification code generation method and device Download PDF

Info

Publication number
CN110677239A
CN110677239A CN201910788699.5A CN201910788699A CN110677239A CN 110677239 A CN110677239 A CN 110677239A CN 201910788699 A CN201910788699 A CN 201910788699A CN 110677239 A CN110677239 A CN 110677239A
Authority
CN
China
Prior art keywords
character
code
characters
verification code
verification
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.)
Granted
Application number
CN201910788699.5A
Other languages
Chinese (zh)
Other versions
CN110677239B (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 Gongtong Electronics Co Ltd
Original Assignee
Shenzhen Gongtong 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 Gongtong Electronics Co Ltd filed Critical Shenzhen Gongtong 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 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.

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 mode 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 requirement of a character terminal in practical application, and 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 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 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 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 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 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.
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 variation provided in this embodiment;
FIG. 5 is a schematic diagram of a verification process provided in the present 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 and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". 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 or implying relative 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 capabilities such as webpage login and application program login, 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 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. 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 this 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 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. 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 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.
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 character lines is multiplied by the number of characters in each line to obtain the total number of 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 confusable character;
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 display symbols 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 seeds 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 scrambling code in this embodiment is a group of special character pairs with visual contrast, for example: the mark, the @ and the M are used for replacing background characters and display symbols of the code, and the display diversity 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 view 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 verification 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 verification code, determining whether the verification code is matched with the verification code sequence according to the verification code array, if so, successfully verifying, enabling the user to carry out next 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 recognition unit is used for recognizing a first character preset in the character sequence; the first character represents a confusable character;
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 its function and inherent logic, 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 steps in the above-described embodiments of the verification code generation method are implemented when the processor 701 executes 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 call the program instruction 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 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 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 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 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.
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 brevity of description, the specific working processes of the terminal and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and 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 (10)

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;
and deforming and combining the code seeds to obtain the verification code.
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 generating 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 in 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 method for generating a verification code according to claim 1, 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.
6. The captcha generating method of claim 5, 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.
7. The verification code generation method of any one of claims 1 to 6, 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.
8. 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;
and the combination unit is used for deforming and combining the code seeds to obtain the verification code.
9. 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 7 when executing the computer program.
10. 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 7.
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 true CN110677239A (en) 2020-01-10
CN110677239B 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)

Cited By (3)

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

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102768754A (en) * 2012-08-03 2012-11-07 网易(杭州)网络有限公司 Method and device for implementation of picture verification code
CN106803904A (en) * 2016-11-24 2017-06-06 德为显示科技股份有限公司 A kind of liquid crystal display OSD display methods and system
CN106899411A (en) * 2016-12-08 2017-06-27 阿里巴巴集团控股有限公司 A kind of method of calibration and device based on identifying code
CN107241327A (en) * 2017-06-06 2017-10-10 北京洋浦伟业科技发展有限公司 The checking code verification method and device of detection are rotated based on character

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102768754A (en) * 2012-08-03 2012-11-07 网易(杭州)网络有限公司 Method and device for implementation of picture verification code
CN106803904A (en) * 2016-11-24 2017-06-06 德为显示科技股份有限公司 A kind of liquid crystal display OSD display methods and system
CN106899411A (en) * 2016-12-08 2017-06-27 阿里巴巴集团控股有限公司 A kind of method of calibration and device based on identifying code
CN107241327A (en) * 2017-06-06 2017-10-10 北京洋浦伟业科技发展有限公司 The checking code verification method and device of detection are rotated based on character

Cited By (4)

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

Also Published As

Publication number Publication date
CN110677239B (en) 2022-09-06

Similar Documents

Publication Publication Date Title
US11936647B2 (en) Identity verification method and apparatus, storage medium, and computer device
US9985786B1 (en) Cross-device authentication
CN110677239B (en) Verification code generation method and device
US9117065B2 (en) Dynamic interactive identity authentication method and system
US9684780B2 (en) Dynamic interactive identity authentication method and system
US9129100B2 (en) Verification code generation and verification method and apparatus
JP5804524B2 (en) User authentication method, apparatus and server
US20150312040A1 (en) Password verifying device and method
EP3203681B1 (en) Sequential biometric cryptosystem and sequential biometric cryptographic processing method
US20160127134A1 (en) User authentication system and method
US20160085958A1 (en) Methods and apparatus for multi-factor user authentication with two dimensional cameras
CN108229956A (en) Network bank business method, apparatus, system and mobile terminal
US20230262057A1 (en) Systems and methods for authenticating users within a computing or access control environment
CN112152806B (en) Cloud-assisted image identification method, device and equipment supporting privacy protection
US20200220715A1 (en) Visual Image Authentication
CN110990811A (en) Identity authentication method and device
US20130191641A1 (en) Captcha (completely automated public test to tell computers and humans apart) data generation methods and related data management systems and computer program products thereof
Khan et al. Mimicry attacks on smartphone keystroke authentication
US9892308B2 (en) Fingerprint recognition methods and devices
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
RU2541868C2 (en) Anti-peep user authentication method

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