CN117556854A - Two-dimensional code generation method and device, electronic equipment and readable medium - Google Patents
Two-dimensional code generation method and device, electronic equipment and readable medium Download PDFInfo
- Publication number
- CN117556854A CN117556854A CN202311302061.9A CN202311302061A CN117556854A CN 117556854 A CN117556854 A CN 117556854A CN 202311302061 A CN202311302061 A CN 202311302061A CN 117556854 A CN117556854 A CN 117556854A
- Authority
- CN
- China
- Prior art keywords
- dimensional code
- content
- generation
- generating
- generated
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Storage Device Security (AREA)
Abstract
The invention provides a two-dimensional code generation method, a two-dimensional code generation device, electronic equipment and a readable medium. The method comprises the following steps: determining whether the two-dimensional code generation content needs simple generation or not; when simple generation is needed, processing the two-dimensional code generation content to obtain a corresponding content value; and generating a two-dimensional code according to the content value. According to the scheme, the original two-dimensional code generation content is converted into the content value, and the two-dimensional code is generated through the content value, so that the problem that the complexity of the two-dimensional code generated by long content is high and the identification is difficult is solved, the generated two-dimensional code is simplified, and the identification rate of the two-dimensional code is improved.
Description
Technical Field
The invention relates to the technical field of two-dimensional codes, in particular to a two-dimensional code generation method, a device, electronic equipment and a readable medium.
Background
In daily work and life, the two-dimensional code has been applied to various places, and most common is the two-dimensional code of paying treasures, weChat two-dimensional code, place code and various public numbers, and we observe different two-dimensional codes, find and have nuances, and the most obvious one is the complexity of two-dimensional code is different, and that is the two-dimensional code looks relatively simple and easy, and the color lump of the two-dimensional code is closely-spaced hemp.
Two attributes affecting the complexity of the two-dimensional code are content length and fault tolerance rate respectively, wherein the content length, as the name implies, the text length contained in the two-dimensional code determines the complexity of the two-dimensional code picture, and the longer the text, the more complex the two-dimensional code, and vice versa, the simpler the text. Two-dimensional codes with different text lengths have different complexity under the same fault tolerance, and recognition failure is often caused by too dense two-dimensional codes with high complexity during recognition.
Therefore, in order to solve the problem of high complexity and difficult recognition of the two-dimensional code, the invention provides a two-dimensional code generation method, which simplifies the content of the generated two-dimensional code and improves the recognition rate of the two-dimensional code.
Disclosure of Invention
The embodiment of the invention provides a two-dimensional code generation method, a device, electronic equipment and a readable medium, which can simplify the content of a generated two-dimensional code so as to improve the recognition rate of the two-dimensional code.
According to an aspect of the present invention, there is provided a two-dimensional code generation method, including:
determining whether the two-dimensional code generation content needs simple generation or not;
when simple generation is needed, processing the two-dimensional code generation content to obtain a corresponding content value;
and generating a two-dimensional code according to the content value.
Optionally, the determining whether the two-dimensional code generation content needs simple generation includes:
determining the byte quantity of the two-dimension code generated content;
when the byte amount is greater than a preset value, it is determined that easy generation is required.
Optionally, the processing the two-dimensional code generated content to obtain a corresponding content value includes:
performing MD5 encryption on the two-dimensional code generation content to obtain encryption information;
storing the encrypted information to redis;
and determining a key value of the encryption information, and taking the key value as the content value.
Optionally, the generating the two-dimensional code according to the content value includes:
determining the fault tolerance rate of the two-dimensional code;
and determining the complexity degree of the two-dimensional code according to the fault tolerance, and generating the two-dimensional code through the key value based on the complexity degree.
Optionally, the method further comprises:
identifying the generated two-dimensional code;
acquiring an identification result, and acquiring the encryption information from redis according to the identification result;
decrypting the encrypted information to obtain the two-dimension code generation content, and performing service processing according to the two-dimension code generation content.
Optionally, the method further comprises:
and when the simple generation is not needed, generating the two-dimension code according to the two-dimension code generation content, and acquiring the two-dimension code generation content by scanning the two-dimension code to perform service processing.
Optionally, the method further comprises:
the two-dimension code generating service and the generated two-dimension code display service are packaged in a control display method, so that the two-dimension code is generated and the generated two-dimension code is displayed through the control display method.
According to another aspect of the present invention, there is provided a two-dimensional code generating apparatus including:
the determining unit is used for determining whether the two-dimensional code generation content needs simple generation or not;
the processing unit is used for processing the two-dimensional code generation content to obtain a corresponding content value when simple generation is needed;
and the generating unit is used for generating a two-dimensional code according to the content value.
According to another aspect of the present invention, there is provided an electronic apparatus including: at least one memory and at least one processor;
the at least one memory for storing a machine readable program;
the at least one processor is configured to invoke the machine readable program to perform the method of any of the embodiments described above.
According to another aspect of the present invention, there is provided a computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method of any of the above embodiments.
The embodiment of the invention provides a two-dimensional code generation method, a device, electronic equipment and a readable medium. Determining whether the two-dimensional code generation content needs simple generation or not; when simple generation is needed, processing the two-dimensional code generation content to obtain a corresponding content value; and generating a two-dimensional code according to the content value. According to the scheme, the original two-dimensional code generation content is converted into the content value, and the two-dimensional code is generated through the content value, so that the problem that the complexity of the two-dimensional code generated by long content is high and the identification is difficult is solved, the generated two-dimensional code is simplified, and the identification rate of the two-dimensional code is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a two-dimensional code generating method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an execution flow of a two-dimensional code generating method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a two-dimensional code generating device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments, and all other embodiments obtained by those skilled in the art without making any inventive effort based on the embodiments of the present invention are within the scope of protection of the present invention.
Fig. 1 is a flowchart of a two-dimensional code generating method according to an embodiment of the present invention, where the method may include the following steps:
s110, determining whether the two-dimensional code generation content needs to be simply generated or not.
In the embodiment of the present invention, the determining whether the two-dimensional code generation content needs simple generation includes:
determining the byte quantity of the two-dimension code generated content;
when the byte amount is greater than a preset value, it is determined that easy generation is required.
The two-dimensional Code is also called as a two-dimensional bar Code, and a common two-dimensional Code is QR Code, and QR is called as Quick Response, and is a coding mode. Compared with the traditional Bar Code Bar Code, the Bar Code can store more information, can also represent that the text length contained in the generated content of more data type two-dimensional codes determines the complexity of a two-dimensional Code picture, and the longer the text, the more complex the two-dimensional Code, and otherwise, the simpler the more simple the text. The complexity of the two-dimensional code is also affected by the fault tolerance, and the two-dimensional codes with different text lengths have different complexity under the same fault tolerance. The fault tolerance of the two-dimensional code is set to four grades: l-low fault-tolerant rate, M-medium fault-tolerant rate, Q-higher fault-tolerant rate and H-high fault-tolerant rate, wherein the fault-tolerant rate with the level L is 7%, the M fault-tolerant rate is 15%, the Q fault-tolerant rate is 25%, the H fault-tolerant rate is 30%, and if the fault-tolerant rate is set to be L in the generation process of a two-dimensional code, the blocked content of the generated two-dimensional code cannot be identified if the blocked content exceeds 7%. The more highly fault-tolerant two-dimensional codes are more complex, most of the most common two-dimensional codes adopt M-level fault-tolerant rate, and the two-dimensional codes tend to be as simple as possible under the condition of ensuring certain fault tolerance. The two-dimensional codes with different fault tolerance levels are also different in complexity. The recognition failure is often caused by too dense two-dimensional codes with high complexity during recognition. When the text length of the two-dimensional code generated content is too long, the complexity of the generated two-dimensional code can be reduced through simple generation, so that the recognition rate is improved.
And S120, when simple generation is needed, processing the two-dimensional code generation content to obtain a corresponding content value.
In the embodiment of the present invention, the processing the two-dimensional code generated content to obtain the corresponding content value includes:
performing MD5 encryption on the two-dimensional code generation content to obtain encryption information;
storing the encrypted information to redis;
and determining a key value of the encryption information, and taking the key value as the content value.
MD5 is an abbreviation of Message-Digest Algorithm, which is a cryptographic hash function widely used by encryption algorithms, and can generate a 128-bit (16-byte) hash value (hash value) to ensure that information transmission is completely consistent. By means of MD5 encryption, the text length of the two-dimensional code generated content can be reduced.
Redis is a short name of Remote Dictionary Server, is a key-value storage system developed by Italian Salvatore Sanfilippo, has extremely high read-write performance, and can read up to 110000 times/s and write up to 81000 times/s.
S130, generating a two-dimensional code according to the content value.
In an embodiment of the present invention, the generating a two-dimensional code according to the content value includes:
determining the fault tolerance rate of the two-dimensional code;
and determining the complexity degree of the two-dimensional code according to the fault tolerance, and generating the two-dimensional code through the key value based on the complexity degree.
When simple generation is selected, the content for generating the two-dimensional code is encrypted through the MD5, the encrypted ciphertext is used as a key value, the content is used as a value and stored in the redis, and then the two-dimensional code is generated by using the key value. The complexity of the generated two-dimensional code can be further adjusted by setting different fault tolerance rates.
In an embodiment of the present invention, the method may further include: identifying the generated two-dimensional code;
acquiring an identification result, and acquiring the encryption information from redis according to the identification result;
decrypting the encrypted information to obtain the two-dimension code generation content, and performing service processing according to the two-dimension code generation content.
The method comprises the steps of identifying the generated two-dimensional code, obtaining an identification result, and then obtaining content corresponding to the two-dimensional code in redis and carrying out service processing.
In an embodiment of the present invention, the method may further include: and when the simple generation is not needed, generating the two-dimension code according to the two-dimension code generation content, and acquiring the two-dimension code generation content by scanning the two-dimension code to perform service processing.
When the text length included in the two-dimensional code generation content is short, the two-dimensional code can be generated without simple generation, and when simple generation is not selected, the two-dimensional code generation method is directly called for generation, the generated two-dimensional code can be pre-identified, an identification result and identification duration are obtained, and whether the simple generation mode is started or not is determined to generate the two-dimensional code according to the identification result.
In an embodiment of the present invention, the method may further include: the two-dimension code generating service and the generated two-dimension code display service are packaged in a control display method, so that the two-dimension code is generated and the generated two-dimension code is displayed through the control display method.
The method comprises the steps of developing based on H5 and java, matching front and rear ends, calling a JS script by the front end, calling a two-dimension code control display method, displaying a complete generating and previewing component, simultaneously, uploading a service maven package by the rear end of java development, which is matched with the front end by the rear end reference, receiving services by files in the maven by the rear end service reference, publishing the services to the outside, and configuring a service address at the front end, so that front and rear end operation of the whole uploading can be completed. H5 is an abbreviation of HyperText Markup Language 5, a language description way to construct Web content, HTML5 is a specification of the core language HTML in the Web, and content that a user sees when browsing a Web page using any means is originally in HTML format. JS vs H5 document element: the method comprises the steps of generating a mode, fault tolerance, generating a two-dimensional code, pre-identifying, generating the two-dimensional code and an element triggering method corresponding to the two-dimensional code, packaging the two-dimensional code in a control display method, and calling the method and setting accessory elements of the method when the method is used so as to display a complete two-dimensional code generating assembly on an interface.
Fig. 2 is a schematic diagram of an execution flow of a two-dimensional code generating method according to an embodiment of the present invention, and the completed work content is as follows:
1. JS vs H5 document element: the method comprises the steps of generating a mode, fault tolerance, generating a two-dimensional code, pre-identifying, generating the two-dimensional code and an element triggering method corresponding to the two-dimensional code, packaging the two-dimensional code in a control display method, and calling the method and setting accessory elements of the method when the method is used so as to display a complete two-dimensional code generating assembly on an interface.
2. When the two-dimension code is generated, the two-dimension code generation content is obtained in the prefabricated extension method, whether the content is converted is determined according to whether the simple generation is selected, when the simple generation is not selected, the two-dimension code generation method is directly called to generate, the generated two-dimension code can be pre-identified, an identification result and identification duration are obtained, and whether the simple generation mode is started to generate the two-dimension code is determined according to the identification result.
3. When the simple generation is selected, the content for generating the two-dimensional code is encrypted through the MD5, the encrypted ciphertext is used as a key value, the content is used as a value and stored in the redis, and then the two-dimensional code is generated by using the key value.
4. And identifying the generated two-dimensional code.
5. The identification result is obtained, and then the real content in redis is obtained.
6. And carrying out service processing on the returned real content.
According to the method, the content which needs to generate the two-dimensional code is simplified, long content used for generating the two-dimensional code is converted into short content, and then the short content is used for generating the two-dimensional code, so that the problem that the complexity of the two-dimensional code generated by the long content is high and the identification is difficult is solved. The method has the following characteristics:
1. the components are developed based on h5 and are not affected by the front end framework component library selection.
2. The client can use the reference js, and the use is flexible and convenient.
3. The content length is reduced, and the recognition accuracy is increased.
4. The two-dimensional code can be pre-identified, and the identification efficiency is perceived.
Fig. 3 is a schematic structural diagram of a two-dimensional code generating device according to an embodiment of the present invention, where the device may include:
a determining unit 410, configured to determine whether the two-dimensional code generation content needs simple generation;
the processing unit 420 is configured to process the two-dimensional code generated content to obtain a corresponding content value when simple generation is required;
and a generating unit 430, configured to generate a two-dimensional code according to the content value.
It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation to the two-dimensional code generating apparatus. In other embodiments of the present invention, the two-dimensional code generating apparatus may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The content of information interaction and execution process between the units in the device is based on the same conception as the embodiment of the method of the present invention, and specific content can be referred to the description in the embodiment of the method of the present invention, which is not repeated here.
The present invention also provides a computer-readable medium storing instructions for causing a computer to execute the two-dimensional code generation method as described herein. Specifically, a system or apparatus provided with a storage medium on which a software program code realizing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or apparatus may be caused to read out and execute the program code stored in the storage medium.
In this case, the program code itself read from the storage medium may realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code form part of the present invention.
Examples of the storage medium for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer by a communication network.
Further, it should be apparent that the functions of any of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform part or all of the actual operations based on the instructions of the program code.
Further, it is understood that the program code read out by the storage medium is written into a memory provided in an expansion board inserted into a computer or into a memory provided in an expansion unit connected to the computer, and then a CPU or the like mounted on the expansion board or the expansion unit is caused to perform part and all of actual operations based on instructions of the program code, thereby realizing the functions of any of the above embodiments.
It should be noted that not all the steps and modules in the above flowcharts and the system configuration diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution sequence of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented jointly by some components in multiple independent devices.
In the above embodiments, the hardware unit may be mechanically or electrically implemented. For example, a hardware unit may include permanently dedicated circuitry or logic (e.g., a dedicated processor, FPGA, or ASIC) to perform the corresponding operations. The hardware unit may also include programmable logic or circuitry (e.g., a general-purpose processor or other programmable processor) that may be temporarily configured by software to perform the corresponding operations. The particular implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
While the invention has been illustrated and described in detail in the drawings and in the preferred embodiments, the invention is not limited to the disclosed embodiments, and those skilled in the art will appreciate that many more embodiments of the invention can be obtained by combining the code audits in the different embodiments and still fall within the scope of the invention.
Claims (10)
1. The two-dimensional code generation method is characterized by comprising the following steps:
determining whether the two-dimensional code generation content needs simple generation or not;
when simple generation is needed, processing the two-dimensional code generation content to obtain a corresponding content value;
and generating a two-dimensional code according to the content value.
2. The method of claim 1, wherein determining whether the two-dimensional code generation content requires easy generation comprises:
determining the byte quantity of the two-dimension code generated content;
when the byte amount is greater than a preset value, it is determined that easy generation is required.
3. The method of claim 1, wherein the processing the two-dimensional code generated content to obtain the corresponding content value includes:
performing MD5 encryption on the two-dimensional code generation content to obtain encryption information;
storing the encrypted information to redis;
and determining a key value of the encryption information, and taking the key value as the content value.
4. The method of claim 3, wherein the generating a two-dimensional code from the content value comprises:
determining the fault tolerance rate of the two-dimensional code;
and determining the complexity degree of the two-dimensional code according to the fault tolerance, and generating the two-dimensional code through the key value based on the complexity degree.
5. A method as claimed in claim 3, further comprising:
identifying the generated two-dimensional code;
acquiring an identification result, and acquiring the encryption information from redis according to the identification result;
decrypting the encrypted information to obtain the two-dimension code generation content, and performing service processing according to the two-dimension code generation content.
6. The method as recited in claim 5, further comprising:
and when the simple generation is not needed, generating the two-dimension code according to the two-dimension code generation content, and acquiring the two-dimension code generation content by scanning the two-dimension code to perform service processing.
7. The method as recited in claim 1, further comprising:
the two-dimension code generating service and the generated two-dimension code display service are packaged in a control display method, so that the two-dimension code is generated and the generated two-dimension code is displayed through the control display method.
8. Two-dimensional code generation device, its characterized in that includes:
the determining unit is used for determining whether the two-dimensional code generation content needs simple generation or not;
the processing unit is used for processing the two-dimensional code generation content to obtain a corresponding content value when simple generation is needed;
and the generating unit is used for generating a two-dimensional code according to the content value.
9. An electronic device, comprising: at least one memory and at least one processor;
the at least one memory for storing a machine readable program;
the at least one processor being configured to invoke the machine readable program to perform the method of any of claims 1 to 7.
10. A computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311302061.9A CN117556854A (en) | 2023-10-09 | 2023-10-09 | Two-dimensional code generation method and device, electronic equipment and readable medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311302061.9A CN117556854A (en) | 2023-10-09 | 2023-10-09 | Two-dimensional code generation method and device, electronic equipment and readable medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN117556854A true CN117556854A (en) | 2024-02-13 |
Family
ID=89815535
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311302061.9A Pending CN117556854A (en) | 2023-10-09 | 2023-10-09 | Two-dimensional code generation method and device, electronic equipment and readable medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117556854A (en) |
-
2023
- 2023-10-09 CN CN202311302061.9A patent/CN117556854A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7349959B2 (en) | Method for creating and processing a soap message, and method, apparatus and program for processing information | |
| CN105512881B (en) | A kind of method and terminal for completing payment based on two dimensional code | |
| CN112559928B (en) | Page processing method and device based on hybrid development, electronic equipment and storage medium | |
| CN110275831B (en) | Mock data verification method and device of protocol interface | |
| CN104796257A (en) | Flexible data authentication | |
| CN113127108B (en) | Business request processing method and device, storage medium and electronic device | |
| CN110362547A (en) | Coding, parsing, storage method and the device of journal file | |
| CN109787768B (en) | Identity authentication configuration method and device and computer readable storage medium | |
| CN113448545A (en) | Method, apparatus, storage medium, and program product for machine learning model servitization | |
| CN110336770A (en) | Method, apparatus, equipment and the storage medium of long-range monitoring loophole | |
| JP3617789B2 (en) | Public key certificate issuance method, verification method, system, and recording medium | |
| US20060075334A1 (en) | Information processing apparatus, history file generation method and program | |
| JP2009252153A (en) | Information processing device and information processing method, and computer program | |
| JP2009252153A5 (en) | ||
| CN117556854A (en) | Two-dimensional code generation method and device, electronic equipment and readable medium | |
| CN119128931B (en) | Key-based data processing method, device, equipment, medium, and program product | |
| CN119402286B (en) | Data transmission method, device, equipment and medium | |
| CN116827637B (en) | Canvas-based data encryption transmission method, system, equipment and medium | |
| CN114297695B (en) | Text encryption method, text decryption method and device | |
| Moebius et al. | Model-driven code generation for secure smart card applications | |
| CN110060310B (en) | File compression methods, devices and equipment | |
| CN114581282A (en) | Method and system for adding watermark to picture | |
| CN115426347B (en) | A bill information page display method and API service device | |
| CN117097507B (en) | Method and device for sending verification text message content, method and device for sending verification text message, electronic device and computer-readable storage medium | |
| CN113656728B (en) | Webpage rendering method and device, electronic equipment and computer readable storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |