Disclosure of Invention
In view of the above problems, the present invention provides a verification code generation method, a verification code verification method, a verification code login system, a verification server, and a computer storage medium, so that a client can obtain a verification code picture and also directly obtain a verification code identifier, so that the client does not need to obtain the verification code identifier from a browser cache, thereby avoiding a failure in obtaining the verification code identifier and improving user experience.
In order to achieve the purpose, the invention adopts the following technical scheme:
a verification code generation method comprises the following steps:
responding to a verification login request of a client, and generating a first verification code, a verification code picture and a corresponding verification code identifier;
sending the first verification code and the corresponding verification code identification to a buffer for associated storage;
and coding the verification code picture, generating a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to a client.
Preferably, the verification code generation method further includes:
receiving a second verification code and a verification code identifier sent by a client, and searching for a corresponding verification code in the cache through the verification code identifier;
judging whether the second verification code is consistent with the corresponding verification code in the buffer;
and when the second verification code is consistent with the corresponding verification code in the buffer, the verification is successful and a verification success prompt is sent to the corresponding client.
Preferably, the verification code generation method further includes:
and when the second verification code is inconsistent with the corresponding verification code in the buffer, sending a verification failure prompt to the corresponding client.
Preferably, in the verification code generation method, the encoding process is a base64 encoding process.
Preferably, in the verification code generation method, the generating a first verification code, a verification code picture and a corresponding verification code identifier includes:
generating the first verification code and a corresponding verification code identifier;
and carrying out picture conversion on the first verification code and carrying out visual confusion processing on the converted picture to generate the verification code picture.
Preferably, in the verification code generation method, the verification code packet is an interface packet in json format.
The invention also provides a verification code verification method, which comprises the following steps:
receiving a verification code message sent by a verification server, wherein the verification code message comprises a picture code and a corresponding verification code identifier;
extracting picture codes in the verification code message, decoding the picture codes, generating and displaying a corresponding verification code picture;
and returning the third verification code input by the user and the verification code identifier in the verification code message to the verification server.
The invention also provides a verification code login system, which comprises a client and a verification server;
the client sends a verification login request to the verification server;
the authentication server responds to an authentication login request of a client and generates a first authentication code, an authentication code picture and a corresponding authentication code identifier; sending the first verification code and the verification code identification to a buffer for associated storage; coding the verification code picture, generating a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to a client;
the client receives a verification code message sent by a verification server, extracts a picture code in the verification code message and carries out decoding processing to generate and display a verification code picture; returning a second verification code input by a user and the verification code identification to the verification server;
and the verification server searches the first verification code in the cache through the verification code identification and judges whether the first verification code is consistent with the second verification code or not so as to execute verification login of the client.
The invention also provides a verification server, which comprises a memory and a processor, wherein the memory is used for storing the computer program, and the processor runs the computer program to enable the verification server to execute the verification code generation method.
The present invention also provides a computer storage medium storing a computer program for use in the authentication server.
The invention provides a verification code generation method, which comprises the following steps: responding to a verification login request of a client, and generating a first verification code, a verification code picture and a corresponding verification code identifier; sending the first verification code and the corresponding verification code identification to a buffer for associated storage; and coding the verification code picture, generating a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to a client. According to the verification code generation method, the verification code identification and the picture code of the verification code picture are combined into a message and then sent to the client, so that the client can obtain the verification code picture and also can directly obtain the verification code identification, the client does not need to obtain the verification code identification from a browser cache, the situation that the verification code identification is failed to obtain is avoided, and the user experience degree is improved.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Hereinafter, the terms "including", "having", and their derivatives, which may be used in various embodiments of the present invention, are only intended to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing, and should not be construed as first excluding the existence of, or adding to, one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing.
Furthermore, the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present invention belong. The terms (such as those defined in commonly used dictionaries) should be interpreted as having a meaning that is consistent with their contextual meaning in the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein in various embodiments of the present invention.
Example 1
Fig. 1 is a flowchart of a verification code generation method provided in embodiment 1 of the present invention, where the method includes the following steps:
step S11: and responding to a verification login request of the client, and generating a first verification code, a verification code picture and a corresponding verification code identifier.
In the embodiment of the invention, the client comprises electronic equipment such as a mobile phone, a tablet personal computer, a computer and the like, the electronic equipment generally has the requirement of logging in an account number on a front-end login page, and when the account number is logged in, an account number and a password are input on the front-end login page, and an authentication code is also required to be input to indicate that a real person logs in the account number, so that the condition of maliciously using a machine or a program to perform batch automatic login operation is prevented.
In the embodiment of the present invention, when receiving a verification login request sent by a client, a verification server generates a verification code of the verification login request, a verification code picture corresponding to the verification code, and a verification code identifier, which specifically includes the following steps: generating the first verification code and a corresponding verification code identifier; and carrying out picture conversion on the first verification code and carrying out visual confusion processing on the converted picture to generate the verification code picture. The random code generator may generate a fixed number of character codes, for example, 4 character codes and more character codes, which are not limited herein, and the character codes include upper and lower case letters, symbols, Chinese characters, and the like. The visual confusion processing is also capable of performing single amplification, reduction, different color processing and the like on the character codes in the picture so as to increase the safety of the verification code. The ID number is unique and is used to identify the verification code, so as to search for the corresponding verification code in the buffer by using the ID number, wherein the verification code identification can be determined according to the time of verification code generation, and is not limited herein.
Step S12: and sending the first verification code and the corresponding verification code identification to a buffer for associated storage.
In the embodiment of the invention, after the verification code and the corresponding verification code identifier are generated, the verification code and the corresponding verification code identifier can be stored in the buffer in an associated manner. The buffer may store a large number of different verification codes and corresponding verification code identifiers in a unified time to process a large number of verification code verification operations in the same time, and the buffer may set a retention time of the verification codes, that is, a failure time of the verification codes, which may be set to 2 minutes or more, for example, which is not limited herein.
Step S13: and coding the verification code picture, generating a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to the client.
In the embodiment of the present invention, after the verification code server generates the verification code picture, the verification code picture is encoded, where the encoding may be base64 encoding, so as to obtain the picture code of the verification code picture, and the picture code and the verification code identifier are combined into the verification code message. When the verification code message is combined, the verification code identifier can be inserted into the picture code according to a preset rule to increase the security of the verification code message and prevent the message from being intercepted and cracked, for example, the verification code identifier can be divided into a plurality of sections according to preset bits, inserted into a preset position of the picture code, and an identifier position is added for marking. The verification code message is an interface message in a json format.
In the prior art, a method for acquiring an authentication code identifier by using a cookie (browser cache) cannot acquire the authentication code identifier when a domain name or a port of a front-end page is different from that of a back-end server, that is, under the condition of cross-domain, so that authentication cannot be completed. In the embodiment of the invention, the verification code identifier combination is added into the picture code to generate the verification code message and the verification code message is sent to the client, so that the client does not need to acquire the verification code identifier from the cookie, the problem that the verification code identifier cannot be acquired in a cross-domain mode is solved, and the user experience is improved.
Example 2
Fig. 2 is a flowchart of a verification code generation method provided in embodiment 2 of the present invention, where the method includes the following steps:
step S21: and responding to a verification login request of the client, and generating a first verification code, a verification code picture and a corresponding verification code identifier.
This step is identical to step S11 described above, and will not be described herein again.
Step S22: and sending the first verification code and the corresponding verification code identification to a buffer for associated storage.
This step is identical to step S12 described above, and will not be described herein again.
Step S23: and coding the verification code picture, generating a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to the client.
This step is identical to step S13 described above, and will not be described herein again.
Step S24: and receiving a second verification code and a verification code identifier sent by the client, and searching for the corresponding verification code in the buffer through the verification code identifier.
In the embodiment of the invention, the verification server can receive the verification code sent by the client and the verification code identification corresponding to the verification code. After receiving the verification code identification sent by the client, the verification server enters the buffer by using the verification code identification for matching so as to obtain the corresponding verification code in the buffer. The process of entering the cache for matching by using the verification code identifier may be implemented by using an algorithm or an application program, for example, an application program may be set in the verification server, and after the application program obtains the verification code identifier sent by the client, the application program may enter the cache by using the verification code identifier to search for the verification code associated with the verification code identifier. When the associated verification code is not found in the buffer, the verification code is expired, and the verification server can send a verification code expiration prompt to the client.
Step S25: and judging whether the second verification code is consistent with the corresponding verification code in the buffer.
Step S26: and when the second verification code is consistent with the corresponding verification code in the buffer, the verification is successful and a verification success prompt is sent to the corresponding client.
In the embodiment of the invention, when the verification code sent by the client is consistent with the corresponding verification code in the verification server, the verification is successful, wherein the verification server can receive the account number and the password sent by the client and verify the verification code, and the client is allowed to log in when the account number and the password are both correct.
In the embodiment of the present invention, the process of determining whether the verification codes are consistent may be implemented by using an algorithm or an application program, for example, an application program for determining the verification codes may be set in the verification server, and after receiving the verification codes of the client and finding the corresponding verification codes in the buffer, the application program may compare the two verification codes to determine whether the two verification codes are consistent.
Step S27: and when the second verification code is inconsistent with the corresponding verification code in the buffer, sending a verification failure prompt to the corresponding client.
In the embodiment of the invention, when the verification code sent by the client is inconsistent with the corresponding verification code in the buffer, the verification server can generate the verification title to the corresponding client, prompt the client to input again or prompt the client to refresh the verification code. When the client refreshes the verification code, the verification server generates a new verification code and a corresponding identifier and picture, and the steps are repeated, and the invalid verification code in the buffer is automatically deleted.
Example 3
Fig. 3 is a flowchart of a verification method for an authentication code according to embodiment 3 of the present invention, where the method includes the following steps:
step S31: and receiving a verification code message sent by a verification server, wherein the verification code message comprises a picture code and a corresponding verification code identifier.
Step S32: and extracting the picture code in the verification code message, decoding the picture code, generating a corresponding verification code picture and displaying the verification code picture.
In the embodiment of the invention, after receiving the verification code message sent by the verification server, the client extracts the picture code and the corresponding verification code identifier in the message. If the information in the verification code message is encrypted, the information can be decrypted by using a preset decryption rule and then extracted. After extracting the picture code, the client converts the picture code into a picture and displays the picture, wherein the picture code is generated by encoding with base64, and then decoding is performed by using a corresponding decoder, which is not limited herein.
Step S33: and returning the third verification code input by the user and the verification code identifier in the verification code message to the verification server.
In the embodiment of the invention, after the user inputs the verification code in the client, the client returns the input verification code and the verification code identifier to the verification code server after packaging so as to carry out verification.
Example 4
Fig. 4 is a schematic structural diagram of an authentication code login system according to embodiment 4 of the present invention.
The verificationcode login system 400 includes a client 410 and a verification server 420;
the client 410 sends an authentication login request to the authentication server 420;
the authentication server 420 generates a first authentication code, an authentication code picture and a corresponding authentication code identifier in response to an authentication login request of the client 410; sending the first verification code and the verification code identification to a buffer for associated storage; coding the verification code picture to generate a corresponding picture code, combining the picture code with a corresponding verification code identifier to generate a verification code message, and sending the verification code message to the client 410;
the client 410 receives the verification code message sent by the verification server 420, extracts the picture code in the verification code message and performs decoding processing to generate and display a verification code picture; returning the second verification code and the verification code identification input by the user to the verification server 420;
the authentication server 420 searches the first authentication code in the register according to the authentication code identifier, and determines whether the first authentication code is consistent with the second authentication code, so as to perform authentication login of the client 410.
In addition, the invention also provides a verification server which can comprise a smart phone, a tablet computer, a vehicle-mounted computer, intelligent wearable equipment and the like. The verification server comprises a memory and a processor, wherein the memory can be used for storing a computer program, and the processor enables the verification server to execute the functions of the modules in the verification code generation method through running the computer program.
The memory may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the authentication server, and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The present embodiment also provides a computer storage medium for storing a computer program used in the authentication server described above.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative and, for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, each functional module or unit in each embodiment of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules 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 invention or a part of the technical solution that contributes to the prior art in essence can be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.