A verification method of a verification code, an electronic device, a computer readable storage medium and a program product
By generating dynamic verification codes that are bound to user permissions and client identifiers, the problem of QR code verification codes being illegally reused is solved, achieving higher confidentiality and verification security.
Patent Information
- Application Number
- CN202611174637.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-11-06
AI Technical Summary
Existing technologies cannot effectively prevent QR code verification codes from being screenshotted, photographed, and illegally reused, especially through screen recording and broadcasting, which leads to the infringement of legitimate users' rights and verification security threats.
The first verification code is generated by obtaining the user's permission information and encoding it. The authentication parameters are generated by combining the client identifier and the code acquisition time. The first verification code is then encoded and transformed to generate the second verification code. The dynamic verification matrix is XORed with the first verification code matrix to generate the second verification code that is bound to the current verification operation.
This reduces the risk of unauthorized use of verification codes after they are screenshotted, copied, or forwarded, and improves the confidentiality of verification codes and the fault tolerance of legitimate users.
Smart Images

Figure CN123052853A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology service technology, and more specifically, to a verification method for verification codes, an electronic device, a computer-readable storage medium, and a program product. Background Technology
[0002] With the widespread adoption of digitalization in services such as electronic ticketing and access verification, electronic verification codes based on QR codes have been widely used in various scenarios, including scenic area entry, venue access, and event check-in. Users obtain a verification code image carrying their access information through a client application, and complete access verification by scanning the code at the verification terminal. However, due to the easy copying and dissemination of QR code images, legitimate and valid verification codes can be easily stolen through screenshots, photos, and screen recordings, and then illegally resold or misused by others. This not only infringes on the rights of operators and legitimate users but also poses a serious threat to verification security. To prevent the illegal reuse of verification codes after being screenshotted or photographed, existing technologies generate access credentials with short validity periods at fixed intervals, encode them as verification codes, and push them to the client for refresh display. Verification codes that have expired cannot pass verification. Dynamic masks, dynamic garbled characters, or watermarks can also be superimposed during client display to reduce the possibility of others directly intercepting and using the verification codes.
[0003] However, short-cycle dynamic refresh solutions can only resist the simple reuse of static screenshots and cannot prevent screen recording and rebroadcasting for unauthorized use. Others can use real-time screen recording and remote video synchronization to broadcast the dynamically refreshed verification code from the legitimate user's end to the verification site in real time. When the verification terminal scans the code, it can still read the valid credential within its validity period, making it impossible to distinguish between the real code holder and the screen recorder. Secondly, in dynamic masking methods, the content changes cyclically according to a fixed period. Others can also record and replay the entire change process, misleading the verification terminal into believing that the currently displayed verification code is changing in real time. Therefore, how to effectively resist the illegal rebroadcasting of verification codes through screenshots, screen recordings, and other means, while ensuring the verification tolerance of legitimate users, is a problem that urgently needs to be solved in this field. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a verification method, electronic device, computer-readable storage medium, and program product for verification codes, which can reduce the risk of legitimate user verification codes being illegally misused by others.
[0005] To achieve the above technical objectives, the technical solution adopted in this application is as follows:
[0006] In a first aspect, embodiments of this application provide a verification method for a verification code, comprising: obtaining a first verification code and verification information for verifying user permissions, wherein the first verification code is encoded based on user permission information, the user permission information includes the effective time and expiration time of the permission, and the user permission status, and the verification information includes a client identifier and a code extraction time;
[0007] The authentication parameters are generated by a preset server based on the verification information. The authentication parameters are randomly generated one-time parameters used to mark the verification operation.
[0008] Based on the verification information and the authentication parameters, the first verification code is encoded and transformed by the client to obtain the second verification code;
[0009] The first verification code and the second verification code are sent to the preset server so that the preset server performs a verification operation.
[0010] According to the first aspect, the step of obtaining a second verification code by encoding and transforming the first verification code through a client based on the verification information and the authentication parameters includes:
[0011] Based on the first verification code, the first verification code matrix corresponding to the first verification code is read through the client.
[0012] Based on the first verification code matrix, the authentication parameters and the verification information, a preset digest operation is performed by the client to obtain a dynamic verification matrix, wherein the dynamic verification matrix has the same matrix size as the first verification code matrix.
[0013] Based on the dynamic verification matrix and the first verification code matrix, the client performs encoding transformation processing to obtain the second verification code.
[0014] According to the first aspect, based on the dynamic verification matrix and the first verification code matrix, the second verification code is obtained by performing encoding transformation processing through the client, including:
[0015] Through the client, based on the first preset value and the second preset value in the dynamic verification matrix, the matrix units in the first verification code matrix are XORed one by one to obtain the second verification code matrix. The first preset value is used to maintain the original encoding of the matrix units in the first verification code matrix, and the second preset value is used to reverse the original encoding of the corresponding matrix units in the first verification code matrix.
[0016] The client generates the second verification code based on the second verification code matrix.
[0017] According to the first aspect, the preset server includes an information processing unit and a verification unit, wherein obtaining the first verification code used to verify user permissions includes:
[0018] The information processing unit generates dynamic address parameters based on the user permission information and the current access time, and the dynamic address parameters are updated according to a preset period.
[0019] Based on the preset access address template and the dynamic address parameters, the information processing unit generates a target access address. The preset access address template includes a fixed address field and a dynamic address field. The target access address is updated according to a preset period.
[0020] The first verification code is obtained by encoding the target access address with a QR code using the client.
[0021] According to the first aspect, after sending the first verification code and the second verification code to the preset server, the method further includes:
[0022] The verification unit of the preset server reads the first verification code and the second verification code respectively, and obtains the first verification code matrix corresponding to the first verification code and the second verification code matrix corresponding to the second verification code respectively.
[0023] The verification unit reads the dynamic verification matrix from the client, and performs the inverse XOR operation on the second verification code matrix and the dynamic verification matrix to obtain the verification matrix.
[0024] Based on the verification matrix, the first verification code matrix is verified by the verification unit to obtain the verification result.
[0025] According to the first aspect, the verification of the first verification code matrix by the verification unit based on the verification matrix to obtain the verification result includes:
[0026] The verification unit compares the first verification code matrix with the verification matrix. If the verification matrix is the same as the first verification code matrix, the verification unit outputs a first verification result indicating successful verification, and the information processing unit updates the user permission status to a first permission status indicating permission failure.
[0027] If the verification matrix is different from the first verification code matrix, the verification unit outputs a second verification result indicating verification failure, and after re-acquiring the first verification code matrix and the verification matrix, the process of comparing the first verification code matrix and the verification matrix through the verification unit is re-executed.
[0028] Secondly, embodiments of this application also provide an electronic device, the electronic device including a processor and a memory coupled to each other, the memory storing a computer program, and when the computer program is executed by the processor, causing the electronic device to perform the method as described in the first aspect.
[0029] Thirdly, embodiments of this application also provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when run on a computer, causes the computer to perform the method described in the first aspect.
[0030] Fourthly, embodiments of this application also provide a program product, characterized in that it includes a computer program, which, when executed by a processor, implements the method described in the first aspect.
[0031] The invention employing the above technical solution has the following advantages:
[0032] This application obtains a first verification code based on user permission information encoding, and generates one-time authentication parameters by combining verification information including client identifier and code extraction time. Further, based on these authentication parameters, the first verification code is encoded and transformed to obtain a second verification code. This second verification code not only associates with user permission information but also establishes a binding relationship with the client and time information corresponding to the current verification operation. The second verification code changes with the authentication parameters and verification information, thereby reducing the risk of unauthorized use after the verification code is screenshotted, copied, or forwarded, and improving the confidentiality of the verification code. Attached Figure Description
[0033] This application can be further illustrated by the non-limiting embodiments given in the accompanying drawings. It should be understood that the following drawings only illustrate some embodiments of this application and should not be considered as limiting the scope. For those skilled in the art, other related drawings can be obtained from these drawings without any inventive effort.
[0034] Figure 1 This is a schematic diagram of the verification method for the verification code provided in the embodiments of this application. Detailed Implementation
[0035] The present application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that similar or identical parts are referred to by the same reference numerals in the drawings or description. Implementations not shown or described in the drawings are forms known to those skilled in the art. In the description of this application, terms such as "first" and "second" are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0036] Please refer to Figure 1This application provides a verification method for a verification code, which can be applied to an electronic device and can be executed or implemented by the electronic device. The electronic device can be, but is not limited to, a personal computer, a smartphone, or other electronic devices. The verification method for the verification code may include the following steps:
[0037] S10 obtains a first verification code and verification information for verifying user permissions. The first verification code is obtained based on the user permission information encoding. The user permission information includes the effective time and expiration time of the permission, as well as the user permission status. The verification information includes the client identifier and the code extraction time.
[0038] S20 generates authentication parameters based on the verification information through a preset server. The authentication parameters are randomly generated one-time parameters used to mark the verification operation.
[0039] S30, based on the verification information and the authentication parameters, performs encoding transformation on the first verification code through the client to obtain the second verification code;
[0040] S40 sends the first verification code and the second verification code to the preset server so that the preset server performs a verification operation.
[0041] In S10, in this embodiment, the client can be an application installed on a mobile terminal, tablet terminal, or self-service terminal, or it can be a code-collecting page running in a browser.
[0042] The first verification code is obtained by encoding user permission information. User permission information originates from permission data corresponding to the user and describes the user's current permissions and the conditions under which those permissions can be used. Encoding user permission information means converting it into a readable and transmittable first verification code according to preset encoding rules. The client can encode the user permission information after obtaining it to obtain the first verification code. User permission information includes the permission's effective and expiration times, as well as the user permission status. The effective and expiration times together define the time range of the user's permissions. If the code generation time is earlier than the permission's effective time, it indicates that the user's permissions have not yet taken effect; if the code generation time is later than the permission's expiration time, it indicates that the user's permissions have exceeded their validity period. The effective and expiration times can be used to restrict the type of service a user can purchase, such as a single-day ticket or a three-day ticket. The user permission status indicates whether the user's permissions are currently available for use. It should be noted that the user permission status can be represented by a status value, status character, or status field. For example, the value "1" can represent an effective status, and the value "0" can represent an ineffective status. It can also be represented by characters such as "valid" or "verified." This application does not limit the specific data format of user permission status. Using the above three pieces of information together as user permission information can avoid misjudgments caused by judging user permissions solely based on time or solely based on user permission status.
[0043] The verification information includes the client identifier and the code generation time. The client identifier is a domain name or ID used to distinguish the current client's identity, determining the specific client identity for the current user's permissions and limiting the verification operation at the device level. The code generation time represents the time when the client generates the first verification code. The code generation time corresponds to the permission's effective and expiration times: by comparing the code generation time with the permission's effective and expiration times, it can be determined whether the first verification code was generated within the valid time range of the user's permissions. In one possible implementation, if the code generation time is outside the permission's effective and expiration time range, the client stops generating the first verification code. In this embodiment, the first verification code can be a QR code, and the encoded content in the first verification code corresponds to the corresponding user permission information.
[0044] In S10, the first verification code can be obtained using a preset server and a client. The preset server includes an information processing unit and a verification unit. Obtaining the first verification code used to verify user permissions includes:
[0045] S11 generates dynamic address parameters based on the user permission information and the current access time through the information processing unit, and the dynamic address parameters are updated according to a preset period.
[0046] S12 generates a target access address based on a preset access address template and the dynamic address parameters through the information processing unit. The preset access address template includes a fixed address field and a dynamic address field. The target access address is updated according to a preset period.
[0047] S13 uses the client to encode the target access address into a QR code to obtain the first verification code.
[0048] In S11, the information processing unit generates dynamic address parameters based on user permission information and the current access time. The current access time is the server time when the information processing unit receives the target access address acquisition request. The information processing unit is a functional unit within a preset server responsible for processing user permission information, time information, and generating dynamic address parameters. It can be implemented by the processor of the preset server executing a corresponding computer program, or by an independent functional module within the preset server. The information processing unit does not necessarily correspond to a separate physical device, but rather represents the processing part of the preset server that undertakes the aforementioned data reading, time division, parameter calculation, and parameter updating functions. The information processing unit segments the current access time according to a preset period, grouping current access times within the same preset period into the same time window. Let the current access time be... The preset cycle is The preset start reference time is The time window number corresponding to the current access time. It can be determined according to the following formula:
[0049]
[0050] in, Indicates the time window number to which the current access time belongs, rounded down; This indicates the length of time that has elapsed since the current access time relative to the initial reference time; This represents the length of a preset period. Through the above processing, different current access times within the same preset period correspond to the same time window number, and the time window number increases accordingly after the current access time enters the next preset period.
[0051] For example, the preset period can be set to 20 seconds. If the current access time is between 10:00:00 and 10:00:19, the information processing unit determines these current access times as the same time window. If the current access time reaches 10:00:20, the information processing unit determines that the current access time has entered the next time window. The preset period of 20 seconds is only one implementation method; in actual applications, other time lengths can be set according to the verification response time and confidentiality requirements.
[0052] After determining the time window number, the information processing unit combines the user permission information with the time window number according to a preset data format. This preset data format specifies the order, field length, and field separation of the permission's effective time, expiration time, user permission status, and time window number, ensuring that identical data forms consistent data to be calculated. For example, the effective time, expiration time, user permission status, and time window number can be arranged sequentially, and each data item can be converted to a unified character format before concatenation. The information processing unit performs a preset digest operation on the combined data and converts the result of the digest operation according to a preset encoding format to obtain dynamic address parameters. Dynamic address parameters can be in the form of strings containing numbers, letters, or a combination of numbers and letters. The preset digest operation can use a digest algorithm that can convert input data into a fixed-length result. The purpose of using digest operation is to compress the user permission information and the current access time into dynamic address parameters of relatively fixed length that do not directly expose the original user permission information. Since the input to the digest operation includes both user permission information and the time window number, the generated dynamic address parameters will change accordingly when the user permission information changes or when the current access time enters a new time window.
[0053] Dynamic address parameters are updated according to a preset period. This means that within the same preset period, the information processing unit generates dynamic address parameters using the current time window number for the same user permission information, and these dynamic address parameters remain unchanged within the preset period. If the current access time enters the next preset period, the information processing unit re-combines and digests the data using the new time window number to generate new dynamic address parameters. In specific implementation, the information processing unit can recalculate the time window number corresponding to the current access time each time it receives a dynamic address parameter retrieval request, and compare this time window number with the time window number used when the dynamic address parameter was generated last time. If they are the same, it means that the current access time is still within the original preset period, and the information processing unit can continue to output the original dynamic address parameters. If they are different, it means that the current access time has entered a new preset period, and the information processing unit regenerates the dynamic address parameters and replaces the original dynamic address parameters with the newly generated ones. The information processing unit can also trigger the above update operation periodically according to the preset period. When the user permission status changes, even if the current access time is still within the same preset period, the information processing unit can regenerate dynamic address parameters based on the changed user permission information. For example, when a user's permission status changes from valid to invalid, the user permission information used for digest calculation changes accordingly, and therefore the generated dynamic address parameters also change. The dynamic address parameters are periodic and reflect the current content of the user permission information, preventing the continued use of dynamic address parameters generated based on the original user permission information after the user's permission status changes.
[0054] In S12, the preset access address template is an address format pre-configured in the information processing unit, used to specify the composition of the target access address. The preset access address template includes a fixed address field and a dynamic address field. The fixed address field is the part of the target access address that remains unchanged across different preset periods, used to determine the corresponding access path. The dynamic address field is the part of the preset access address template specifically used to write dynamic address parameters; its content changes with the dynamic address parameters. For example, the preset access address template can be represented as: fixed address field / dynamic address field / fixed address field. In one example, it can be represented as: https: / / target address / dynamic address field / en. The fixed address field remains unchanged; whenever the dynamic address parameters change, the content of the dynamic address field changes accordingly, and the final target access address also changes. The target access address is updated according to a preset period, meaning that the dynamic address parameters in the dynamic address field are replaced according to the preset period, thereby updating the entire target access address. For example, in the first preset period, the dynamic address parameter is: SCBTLL, and the corresponding generated target access address can be: fixed address field / SCBTLL / fixed address field; after entering the next preset period, the dynamic address parameter is updated to: KDPXQF, and the target access address is updated accordingly to: fixed address field / KDPXQF / fixed address field.
[0055] In step S13, the client encodes the target access address generated by the information processing unit into a QR code to obtain the first verification code. After generating the target access address, the information processing unit provides it to the client. The client uses the target access address as the encoding content of the QR code, converts the characters in the target access address into corresponding black and white modules according to the QR code encoding standard, and generates a QR code graphic composed of multiple black and white modules, thus obtaining the first verification code. Within the same preset period, the target access address remains unchanged, and the first verification code generated by the client based on this target access address also remains unchanged. When the target access address enters the next preset period and is updated, the client re-executes the QR code encoding with the updated target access address, thereby generating an updated first verification code. It should be noted that if the client receives the same target access address multiple times within the same preset period, it can continue to display the first verification code already generated based on that target access address without needing to generate it again.
[0056] In S20, when a client performs a code retrieval, it provides the corresponding verification information to the preset server. The client identifier in the verification information identifies the client currently performing the code retrieval operation and can be represented by pre-assigned characters, numbers, domain names, or a combination of characters and numbers. The code retrieval time indicates the time when the client initiated or executed the code retrieval operation. Based on the client identifier and code retrieval time, the preset server can determine the verification operation that requires generating authentication parameters, avoiding the misattribution of authentication parameters generated for one client to another, or the use of authentication parameters from a previous code retrieval operation for a subsequent one. After determining the current verification operation, the preset server calls a preset random number generator to generate part of the authentication parameters. The random number generator can generate random binary data of a preset length and then convert the random binary data into a numeric string, an alphanumeric string, or a string combining letters and numbers. For example, the preset server can generate 128 bits of random data and convert it into a hexadecimal string to obtain the authentication parameters. The above length and encoding format are merely examples. This application does not limit the specific number of bits or the representation of the authentication parameters, as long as the authentication parameters generated by different verification operations have sufficient differences.
[0057] In one possible implementation, the preset server can generate authentication parameters according to the following process: First, it reads the client identifier and code-providing time from the verification information and establishes the current verification operation based on the client identifier and code-providing time. Then, it generates candidate parameters through a random number generation program. The candidate parameters are a portion of the authentication parameters randomly generated by the preset server, while the remaining part of the authentication parameters consists of characters converted from the client identifier and code-providing time. That is, the client identifier and code-providing time are converted into character objects used to establish the authentication parameters, and the random generation process is used to ensure that the authentication parameters themselves are uncertain. For example, the client identifier in the verification information is "001", and it corresponds to the code-providing time 202607051012. The preset server randomly generates the candidate parameter "A7F3C921". The preset server combines the above three pieces of information: "001-202607051012-A7F3C921" and generates authentication parameters according to string processing rules. Verification operations performed by other clients or by the same client at other code-providing times should regenerate authentication parameters; therefore, the authentication parameters are one-time parameters. After the current verification operation is completed, the authentication parameters will not be used in new verification operations. If the client re-initiates the code retrieval, even if the client identifier has not changed, the default server should still regenerate new authentication parameters. Therefore, when the same client performs two code retrieval operations consecutively, it can obtain different authentication parameters. By adding randomly generated authentication parameters to each verification operation, the default server can further differentiate between different verification operations. Even if someone obtains relevant data from a previous verification operation, it will be difficult to directly use it for a new verification operation, thereby improving confidentiality.
[0058] In S30, the step of obtaining a second verification code by encoding and transforming the first verification code through the client based on the verification information and the authentication parameters includes:
[0059] S31 Based on the first verification code, read the first verification code matrix corresponding to the first verification code through the client;
[0060] S32 performs a preset digest operation on the client based on the first verification code matrix, the authentication parameters and the verification information to obtain a dynamic verification matrix, wherein the dynamic verification matrix has the same matrix size as the first verification code matrix;
[0061] S33 performs encoding transformation processing on the client based on the dynamic verification matrix and the first verification code matrix to obtain the second verification code.
[0062] In S31, the first verification code matrix is a matrix of data formed by arranging the coding units in the first verification code according to their row and column positions. It is used to represent the graphic structure of the first verification code in a computable data form. In this embodiment, a QR code can be used as the verification code. During QR code generation, the data to be encoded is arranged into several rows and columns of coding units according to the QR code encoding rules, and a corresponding black and white module graphic is generated based on the value of each coding unit. The matrix formed by the coding units is the first verification code matrix. Therefore, when the client reads the first verification code, it can directly read the matrix encoding result generated by the client during the generation of the first verification code to obtain the first verification code matrix.
[0063] In S32, the client reads each matrix unit in the first checksum matrix according to a preset reading order. For example, it can start from the first row and read each matrix unit sequentially from left to right and from top to bottom, converting the two-dimensional first checksum matrix into first matrix data. For example, if the first checksum matrix is:
[0064]
[0065] Reading from left to right and top to bottom yields the first matrix data: 101010110. The preset digest operation can employ a digest algorithm capable of converting input data of arbitrary length into fixed-length output data. The first matrix data, authentication parameters, client identifier, and code extraction time are combined in a preset order to obtain the data to be digested, and the preset digest operation is performed on this data. The preset digest operation outputs a fixed-length digest, while the dynamic verification matrix needs to have the same matrix size as the first verification code matrix. For example, the first verification code matrix is... If the matrix is large enough, then the dynamic verification matrix needs to include 441 matrix elements. If a single digest operation outputs 256 bits of digest data, then the digest data is insufficient to fill 441 matrix elements. The client can calculate the first and second digest data separately, concatenate the two digest data to obtain 512 bits of data, and then select the first 441 bits as the dynamic verification data. By repeating the digest expansion process according to the total number of matrix elements, the length of the resulting digest data is not less than the total number of matrix elements.
[0066] The client obtains the contents After obtaining the dynamic verification data for each value, the dynamic verification data is filled into a matrix according to the order corresponding to the reading of the first verification code matrix. In a two-dimensional matrix, a dynamic verification matrix is obtained. Since the length of the dynamic verification data is equal to the total number of matrix elements in the first verification code matrix, and the client arranges the data according to the number of rows and columns of the first verification code matrix, the dynamic verification matrix and the first verification code matrix have the same matrix size. Matrix elements at the same row and column positions in both can form a one-to-one correspondence. It should be noted that although the dynamic verification matrix and the first verification code matrix have the same number of rows and columns, they may not contain the same matrix element values. The first verification code matrix reflects the original black and white module arrangement of the first verification code, while the dynamic verification matrix is obtained by performing a preset digest operation on the first verification code matrix, authentication parameters, and verification information; its matrix element arrangement is usually different from that of the first verification code matrix.
[0067] In S33, based on the dynamic verification matrix and the first verification code matrix, the client performs encoding transformation processing to obtain the second verification code, including:
[0068] S331 uses the client to perform XOR calculations on each matrix unit in the first verification code matrix according to the first preset value and the second preset value in the dynamic verification matrix to obtain the second verification code matrix. The first preset value is used to maintain the original encoding of the matrix unit in the first verification code matrix, and the second preset value is used to reverse the original encoding of the corresponding matrix unit in the first verification code matrix.
[0069] S332 generates the second verification code based on the second verification code matrix through the client.
[0070] In S331-S332, let the first verification code matrix be: The dynamic verification matrix is: The second verification code matrix is: ,in, and These represent the number of rows and columns of the matrix, respectively. Indicates the first verification code matrix. line, number Column matrix units; Represents the matrix elements at the same position in the dynamic verification matrix; This represents the matrix elements at the same position in the second verification code matrix obtained after XOR calculation.
[0071] The client calculates the matrix elements in the second verification code matrix one by one according to the following formula:
[0072]
[0073] in," The symbol "" indicates an XOR operation. The basic rule of XOR is: when the two values involved in the calculation are the same, the result is 0; when the two values are different, the result is 1.
[0074] In one specific implementation, both the first verification code matrix and the dynamic verification matrix are represented in binary form, with a first preset value set to 0 and a second preset value set to 1. The values 0 and 1 in the first verification code matrix correspond to two encoding states in the first verification code, for example, 0 can correspond to a white matrix unit, and 1 to a black matrix unit. The correspondence between black and white can also be reversed, as long as the first verification code matrix, the dynamic verification matrix, and the second verification code matrix use a unified encoding rule. The first and second preset values in the dynamic verification matrix do not directly replace the matrix units in the first verification code matrix, but are used to control whether the corresponding matrix units change. Specifically, when a matrix unit at a certain position in the dynamic verification matrix is the first preset value, this first preset value is XORed with the matrix unit at the same position in the first verification code matrix. Regardless of whether the matrix unit in the first verification code matrix is 0 or 1, the calculation result is the same as the original value. Therefore, the first preset value is used to maintain the original encoding of the corresponding matrix unit in the first verification code matrix. When a matrix cell at a certain position in the dynamic verification matrix has a second preset value, this second preset value is XORed with the matrix cell at the same position in the first verification code matrix. If the matrix cell in the first verification code matrix was originally 0, the result becomes 1; if it was originally 1, the result becomes 0. Therefore, the second preset value is used to reverse the original encoding of the corresponding matrix cell in the first verification code matrix. For example, the first verification code matrix is: The dynamic verification matrix is: Then we obtain the second verification code matrix: In S332, the generation method of the first verification code can be referenced. It will not be elaborated here. The client converts different values into corresponding graphic encoding states according to the row and column positions of each matrix unit in the second verification code matrix, thus obtaining the second verification code. Since the dynamic verification matrix is obtained by performing a preset digest operation based on the first verification code matrix, authentication parameters, and verification information, when the authentication parameters or verification information change, the arrangement of the first and second preset values in the dynamic verification matrix usually changes as well. This causes the positions of the inverted matrix units in the first verification code matrix to change, ultimately resulting in different second verification code matrices.
[0075] Unlike existing technologies that periodically refresh or obscure the verification code for confidentiality, the second verification code is generated by encoding and transforming the first verification code matrix, authentication parameters, and verification information including client identifier and code retrieval time. This allows the second verification code to simultaneously associate multiple parameters that can only be obtained from a legitimate user's client. Even if the first verification code is captured by screenshot or photograph within its validity period, a third party cannot generate a second verification code that matches the current verification operation based solely on the first verification code, thus increasing the difficulty of misuse if the first verification code is leaked. Different verification operations correspond to different authentication parameters, and when the verification information changes, the dynamic verification matrix and the second verification code will also change accordingly. Therefore, the second verification code obtained from previously captured screenshots, screen recordings, or forwarded messages only corresponds to the original verification operation and cannot be directly used for new verification operations, thereby reducing the risk of historical verification screens being repeatedly played or reused. Compared to updating the first verification code only at fixed intervals, the second verification code further binds the verification code to a single verification operation, enabling the default server to distinguish between the verification code generated in real-time by the client for the current verification operation and historically acquired verification codes. Furthermore, the second verification code modifies the original encoding state of some matrix units in the first verification code matrix through a dynamic verification matrix, so that the second verification code does not directly present the original complete encoding arrangement of the first verification code graphically. In the absence of a corresponding dynamic verification matrix, third parties cannot directly recover the user permission information carried by the first verification code based solely on the second verification code, thus further obscuring the original encoded content of the first verification code.
[0076] In S40, after sending the first verification code and the second verification code to the preset server, the method further includes:
[0077] S41 reads the first verification code and the second verification code respectively through the verification unit of the preset server, and obtains the first verification code matrix corresponding to the first verification code and the second verification code matrix corresponding to the second verification code respectively.
[0078] S42 reads the dynamic verification matrix in the client through the verification unit, and performs the inverse operation of XOR calculation based on the second verification code matrix and the dynamic verification matrix to obtain the verification matrix;
[0079] S43 verifies the first verification code matrix through the verification unit based on the verification matrix to obtain the verification result.
[0080] In steps S41-S42, the verification unit is a functional unit in the preset server used to read verification codes, perform matrix operations, and obtain verification results. The verification unit can be implemented by the processor of the preset server executing a corresponding computer program. After the first and second verification codes are sent to the preset server, the verification unit processes them according to the same verification code reading rules. Specifically, the verification unit determines the matrix regions in the first and second verification codes, reads the corresponding encoding states according to the row and column positions of each matrix unit, and converts different encoding states into preset values. For example, black matrix units can be converted to the value 1, and white matrix units can be converted to the value 0, thereby obtaining the first verification code matrix and the second verification code matrix, respectively.
[0081] The verification unit performs the inverse XOR operation between each matrix element of the second verification code matrix and the corresponding matrix elements of the dynamic verification matrix to obtain the verification matrix. It should be noted that the inverse XOR operation is not a different computation from XOR itself, but rather utilizes the reversibility of XOR to perform a unit-by-unit XOR operation between the second verification code matrix and the dynamic verification matrix used to generate the second verification code. Since a value can be restored by performing XOR operations twice consecutively with the same value, the encoding transformation caused by the dynamic verification matrix can be eliminated by performing another XOR operation.
[0082] In the specific execution process, the verification unit first determines the matrix size of the second verification code matrix and the dynamic verification matrix. Since the dynamic verification matrix is set to have the same matrix size as the first verification code matrix during generation, and the second verification code matrix is obtained by XORing each matrix element of the first verification code matrix and the dynamic verification matrix, the second verification code matrix and the dynamic verification matrix also have the same number of rows and columns.
[0083] The verification unit can traverse each matrix cell in the second verification code matrix in a left-to-right, top-to-bottom order. For each matrix position, the verification unit reads the matrix cell in the second verification code matrix and the matrix cell in the same row and column of the dynamic verification matrix, performs an XOR operation on the two, and writes the result into the same position in the verification matrix. After completing the calculation of all matrix cells, the complete verification matrix is obtained.
[0084] For example, the first verification code matrix is: The dynamic verification matrix is: The client performs an XOR operation between the first verification code matrix and the dynamic verification matrix to obtain the second verification code matrix: The verification unit reads the second verification code matrix and the corresponding dynamic verification matrix, and performs an XOR calculation again: This yields the verification matrix: It can be seen that the obtained verification matrix is the same as the original first verification code matrix.
[0085] If the dynamic verification matrix read by the verification unit is the same as the dynamic verification matrix used when generating the current second verification code, the encoding transformation can be eliminated through the inverse operation of XOR, resulting in a verification matrix corresponding to the first verification code matrix. If a dynamic verification matrix corresponding to other verification operations is used, some matrix units cannot be correctly recovered, and the resulting verification matrix is usually different from the first verification code matrix. From the perspective of verification code confidentiality, the second verification code matrix does not directly maintain the original encoding arrangement of the first verification code matrix, but rather includes the encoding changes implemented by the dynamic verification matrix. Without obtaining the dynamic verification matrix that correctly corresponds to the second verification code matrix, it is difficult to correctly recover the first verification code matrix from the second verification code matrix. The verification unit can only generate the verification matrix by utilizing the invertibility of XOR operation after obtaining the dynamic verification matrix corresponding to the current verification operation.
[0086] In S43, the step of verifying the first verification code matrix through the verification unit based on the verification matrix to obtain a verification result includes: comparing the first verification code matrix with the verification matrix through the verification unit; if the verification matrix is the same as the first verification code matrix, then the verification unit outputs a first verification result indicating successful verification, and the information processing unit updates the user permission status to a first permission status indicating permission failure; if the verification matrix is different from the first verification code matrix, then the verification unit outputs a second verification result indicating verification failure, and after re-acquiring the first verification code matrix and the verification matrix, the step of comparing the first verification code matrix with the verification matrix through the verification unit is re-executed.
[0087] In S43, the verification unit is a functional unit in the preset server used to read verification codes, perform matrix calculations, compare matrices, and output verification results. The information processing unit is used to manage user permission information and update user permission status based on the verification results. Both can be implemented by different computer programs executed by the processor in the preset server. The verification unit first determines whether the matrix size of the first verification code matrix and the verification matrix are the same. If the number of rows or columns of the two matrices are different, they cannot form a complete positional correspondence, and it can be directly determined that the first verification code matrix and the verification matrix are different. If the matrix sizes are the same, the verification unit reads the matrix units in the same row and column of the two matrices in a preset order and compares them one by one. Only when all corresponding matrix units are the same is it determined that the verification matrix and the first verification code matrix are the same. If even one corresponding matrix unit is different, it is determined that the verification matrix and the first verification code matrix are different.
[0088] If the verification matrix is the same as the first verification code matrix, it means that the second verification code matrix can correctly recover the first verification code matrix under the action of the current dynamic verification matrix. Since the dynamic verification matrix is obtained by performing a preset digest operation based on the first verification code matrix, authentication parameters, and verification information, the ability to correctly recover the first verification code matrix indicates that there is a correct correspondence between the second verification code participating in the current verification, the current first verification code, authentication parameters, and verification information. In this case, the verification unit outputs a first verification result indicating successful verification. The first verification result indicates that the current first verification code and second verification code have passed verification. For example, it can be represented by characters such as "verification successful," and this application does not limit its specific data format. After outputting the first verification result, the information processing unit determines the user permission information corresponding to the first verification code and updates the user permission status in the user permission information to the first permission status. The first permission status represents the state of permission invalidation and can be represented by a numerical value, a character, or a status field. The first permission status can indicate that the user permission has been verified and cannot be used for new verification operations. Since the subsequent first verification code is generated based on user permission information, once the user's permission status has been updated to the first permission status, that user permission no longer has the validity to be used. Updating the user permission status prevents the first and second verification codes that have already been successfully used from being used again. Even if someone else saves the first or second verification code displayed when the verification was successful, the original user permission is no longer valid because the user's permission status on the server has been updated to the first permission status.
[0089] If the first verification code matrix and the verification matrix have different matrix sizes, or if at least one corresponding matrix element in the two matrices is different, the verification unit determines that the verification matrix is different from the first verification code matrix and outputs a second verification result indicating verification failure. When verification fails, the information processing unit does not update the user's permission status to the first permission status. That is, a single matrix recovery failure does not directly invalidate the user's permissions. This avoids the erroneous cancellation of legitimate user permissions due to network anomalies, incomplete verification code display, or reading errors. After outputting the second verification result, the matrix comparison is performed again after re-obtaining the corresponding first verification code matrix and verification matrix. Specifically, during re-verification, the first and second verification codes can be reread, and the verification matrix can be re-obtained based on the re-read second verification code matrix and the corresponding dynamic verification matrix. The re-obtained verification matrix is then compared with the first verification code matrix. This prevents erroneous, historical, or illegally converted second verification codes from passing verification while avoiding a single verification failure directly damaging the legitimate user's permissions.
[0090] This application provides an electronic device that may include a processing module and a memory. The memory stores a computer program, which, when executed by the processor, enables the electronic device to perform the corresponding steps in the verification code verification method described above.
[0091] In this embodiment, the processor can be an integrated circuit chip with signal processing capabilities. For example, the processor can be a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0092] The memory can be, but is not limited to, random access memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, etc.
[0093] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the electronic device described above can be referred to the corresponding steps in the aforementioned method, and will not be elaborated further here.
[0094] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to perform the verification method for the verification code as described in the above embodiments.
[0095] Computer-readable storage media may be magnetic disks, optical disks, read-only memory, random access memory, flash memory, USB flash drives, hard disks, or solid-state drives, etc., and may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implement the methods shown in the above embodiments.
[0096] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the verification code verification method described above. The computer program product may exist in a computer-readable storage medium in forms including, but not limited to, source files, executable files, and installation package files.
[0097] Based on the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by hardware or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application can be embodied in the form of a software product. This software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, electronic device, or network device, etc.) to execute the methods described in the various implementation scenarios of this application.
[0098] In the embodiments provided in this application, it should be understood that the disclosed methods can also be implemented in other ways. The method embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or part of code, which includes one or more executable instructions for implementing a specified logical function. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0099] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A verification method for a verification code, characterized in that, The method includes: Obtain a first verification code and verification information for verifying user permissions. The first verification code is obtained based on the user permission information encoding. The user permission information includes the effective time and expiration time of the permission, as well as the user permission status. The verification information includes the client identifier and the code extraction time. The authentication parameters are generated by a preset server based on the verification information. The authentication parameters are randomly generated one-time parameters used to mark the verification operation. Based on the verification information and the authentication parameters, the first verification code is encoded and transformed by the client to obtain the second verification code; The first verification code and the second verification code are sent to the preset server so that the preset server performs a verification operation.
2. The method according to claim 1, characterized in that, The step of obtaining a second verification code by encoding and transforming the first verification code through the client based on the verification information and the authentication parameters includes: Based on the first verification code, the first verification code matrix corresponding to the first verification code is read through the client. Based on the first verification code matrix, the authentication parameters and the verification information, a preset digest operation is performed by the client to obtain a dynamic verification matrix, wherein the dynamic verification matrix has the same matrix size as the first verification code matrix. Based on the dynamic verification matrix and the first verification code matrix, the client performs encoding transformation processing to obtain the second verification code.
3. The method according to claim 2, characterized in that, Based on the dynamic verification matrix and the first verification code matrix, the client performs encoding transformation processing to obtain the second verification code, including: Through the client, based on the first preset value and the second preset value in the dynamic verification matrix, the matrix units in the first verification code matrix are XORed one by one to obtain the second verification code matrix. The first preset value is used to maintain the original encoding of the matrix units in the first verification code matrix, and the second preset value is used to reverse the original encoding of the corresponding matrix units in the first verification code matrix. The client generates the second verification code based on the second verification code matrix.
4. The method according to claim 3, characterized in that, The preset server includes an information processing unit and a verification unit. Obtaining the first verification code used to verify user permissions includes: The information processing unit generates dynamic address parameters based on the user permission information and the current access time, and the dynamic address parameters are updated according to a preset period. Based on the preset access address template and the dynamic address parameters, the information processing unit generates a target access address. The preset access address template includes a fixed address field and a dynamic address field. The target access address is updated according to a preset period. The first verification code is obtained by encoding the target access address with a QR code using the client.
5. The method according to claim 4, characterized in that, After sending the first verification code and the second verification code to the preset server, the process further includes: The verification unit of the preset server reads the first verification code and the second verification code respectively, and obtains the first verification code matrix corresponding to the first verification code and the second verification code matrix corresponding to the second verification code respectively. The verification unit reads the dynamic verification matrix from the client, and performs the inverse XOR operation on the second verification code matrix and the dynamic verification matrix to obtain the verification matrix. Based on the verification matrix, the first verification code matrix is verified by the verification unit to obtain the verification result.
6. The method according to claim 5, characterized in that, The step of verifying the first verification code matrix based on the verification matrix through the verification unit to obtain the verification result includes: The verification unit compares the first verification code matrix with the verification matrix. If the verification matrix is the same as the first verification code matrix, the verification unit outputs a first verification result indicating successful verification, and the information processing unit updates the user permission status to a first permission status indicating permission failure. If the verification matrix is different from the first verification code matrix, the verification unit outputs a second verification result indicating verification failure, and after re-acquiring the first verification code matrix and the verification matrix, the process of comparing the first verification code matrix and the verification matrix through the verification unit is re-executed.
7. An electronic device, characterized in that, The electronic device includes a processor and a memory coupled together, the memory storing a computer program that, when executed by the processor, causes the electronic device to perform the method as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 6.
9. A program product, characterized in that, It includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 6.
