CN111027656A - Two-dimensional code generation and identification method and device, electronic equipment and storage medium - Google Patents

Two-dimensional code generation and identification method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111027656A
CN111027656A CN201911118805.5A CN201911118805A CN111027656A CN 111027656 A CN111027656 A CN 111027656A CN 201911118805 A CN201911118805 A CN 201911118805A CN 111027656 A CN111027656 A CN 111027656A
Authority
CN
China
Prior art keywords
character string
link
short
url
url link
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911118805.5A
Other languages
Chinese (zh)
Other versions
CN111027656B (en
Inventor
张莹
钱鸿强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Koubei Network Technology Co Ltd
Original Assignee
Zhejiang Koubei Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Koubei Network Technology Co Ltd filed Critical Zhejiang Koubei Network Technology Co Ltd
Priority to CN201911118805.5A priority Critical patent/CN111027656B/en
Publication of CN111027656A publication Critical patent/CN111027656A/en
Application granted granted Critical
Publication of CN111027656B publication Critical patent/CN111027656B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record 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/06009Record 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/06037Record 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9554Retrieval from the web using information identifiers, e.g. uniform resource locators [URL] by using bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9566URL specific, e.g. using aliases, detecting broken or misspelled links

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Transfer Between Computers (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The specification provides a two-dimensional code generation and identification method, a two-dimensional code generation and identification device, electronic equipment and a storage medium; the generation method may include: acquiring a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of the sub-links into a corresponding long character string; replacing the long character string contained in the target URL link with a short character string according to a preset mapping relation between the long character string and the short character string so as to obtain a short URL link corresponding to the target URL link; and generating a two-dimensional code based on the short URL link.

Description

Two-dimensional code generation and identification method and device, electronic equipment and storage medium
Technical Field
One or more embodiments of the present disclosure relate to the field of encoding technologies, and in particular, to a two-dimensional code generation and identification method, apparatus, electronic device, and storage medium.
Background
The two-dimensional code is a black and white pattern which is distributed on a plane (in a two-dimensional direction) according to a certain rule by adopting a specific geometric figure. The two-dimensional code skillfully utilizes the concepts of '0' and '1' bit streams forming the internal logic foundation of a computer in code programming, uses a plurality of geometric shapes corresponding to binary systems to represent character numerical value information, and further an image input device or a photoelectric scanning device can automatically read the meaning represented by the two-dimensional code. In the related art, a URL (uniform resource Locator) link may be converted into a two-dimensional code, so that a user may access a network resource corresponding to the URL link by scanning the two-dimensional code.
Disclosure of Invention
In view of this, one or more embodiments of the present specification provide a two-dimensional code generation and identification method, an apparatus, an electronic device, and a storage medium.
To achieve the above object, one or more embodiments of the present disclosure provide the following technical solutions:
according to a first aspect of one or more embodiments of the present specification, there is provided a two-dimensional code generation method, including:
acquiring a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of the sub-links into a corresponding long character string;
replacing the long character string contained in the target URL link with a short character string according to a preset mapping relation between the long character string and the short character string so as to obtain a short URL link corresponding to the target URL link;
and generating a two-dimensional code based on the short URL link.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Optionally, the obtaining the target URL link includes:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; alternatively, the first and second electrodes may be,
acquiring the original URL link;
and respectively encoding each level of sub-links in the original URL link by adopting the URL encoding algorithm to obtain the target URL link.
Optionally, a one-to-one correspondence relationship is formed between the long character string obtained by encoding any one of the separation character strings by using the URL encoding algorithm and the any one of the separation character strings; and the long character strings and the short character strings in the mapping relation are in one-to-one correspondence.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
According to a second aspect of one or more embodiments of the present specification, there is provided a two-dimensional code recognition method including:
analyzing the target two-dimensional code to obtain a short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link comprising multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string;
acquiring a reduction result aiming at the short URL link, and taking the reduction result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Alternatively to this, the first and second parts may,
the mapping relation is configured locally; the obtaining of the restoration result for the short URL link includes: replacing short character strings contained in the short URL links with long character strings according to the locally configured mapping relation; alternatively, the first and second electrodes may be,
the obtaining of the restoration result for the short URL link includes: sending the short URL link to a reduction server so that the reduction server replaces a short character string contained in the short URL link with a long character string according to the mapping relation; and receiving the replaced URL link returned by the restoring server as the restoring result of the short URL link.
Optionally, the short character string in the mapping relationship includes a short character string identifier; obtaining a reduction result of the short URL link by the following method:
identifying a short string in the short URL link according to the short string identification,
and replacing the identified short character string with a long character string according to the mapping relation.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
According to a third aspect of one or more embodiments of the present specification, there is provided a two-dimensional code generating apparatus including:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target URL link, the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of sub-links into a corresponding long character string;
the replacing unit is used for replacing the long character string contained in the target URL link with the short character string according to the mapping relation between the preset long character string and the preset short character string so as to obtain the short URL link corresponding to the target URL link;
and the generating unit is used for generating a two-dimensional code based on the short URL link.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Optionally, the obtaining unit is specifically configured to:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; alternatively, the first and second electrodes may be,
acquiring the original URL link;
and respectively encoding each level of sub-links in the original URL link by adopting the URL encoding algorithm to obtain the target URL link.
Optionally, a one-to-one correspondence relationship is formed between the long character string obtained by encoding any one of the separation character strings by using the URL encoding algorithm and the any one of the separation character strings; and the long character strings and the short character strings in the mapping relation are in one-to-one correspondence.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
According to a fourth aspect of one or more embodiments of the present specification, there is provided a two-dimensional code recognition apparatus including:
the analysis unit is used for analyzing the target two-dimensional code to obtain the short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link comprising multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string;
an acquisition unit that acquires a restoration result for the short URL link, and takes the restoration result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Alternatively to this, the first and second parts may,
the mapping relation is configured locally; the obtaining unit is specifically configured to: replacing short character strings contained in the short URL links with long character strings according to the locally configured mapping relation; alternatively, the first and second electrodes may be,
the obtaining unit is specifically configured to: sending the short URL link to a reduction server so that the reduction server replaces a short character string contained in the short URL link with a long character string according to the mapping relation; and receiving the replaced URL link returned by the restoring server as the restoring result of the short URL link.
Optionally, the short character string in the mapping relationship includes a short character string identifier; obtaining a reduction result of the short URL link by the following method:
identifying a short string in the short URL link according to the short string identification,
and replacing the identified short character string with a long character string according to the mapping relation.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
According to a fifth aspect of one or more embodiments herein, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of the first aspect by executing the executable instructions.
According to a sixth aspect of one or more embodiments herein, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method according to the second aspect by executing the executable instructions.
According to a seventh aspect of one or more embodiments of the present description, a computer-readable storage medium is proposed, on which computer instructions are stored, which instructions, when executed by a processor, implement the steps of the method according to the first aspect.
According to an eighth aspect of one or more embodiments of the present description, a computer-readable storage medium is proposed, on which computer instructions are stored, which instructions, when executed by a processor, implement the steps of the method according to the second aspect.
In an embodiment of the present specification, the original URL link includes multiple levels of nested child links, the child links at each level are distinguished by a separation character string, and when the child link content itself also includes a separation character string (i.e., the separation character string belongs to at least a part of the content of the child link), the separation character string included in the child link content itself has a problem of "confusion", and the child links at each level cannot be correctly identified based on the separation character string. Therefore, the URL encoding algorithm is adopted to encode the separator strings corresponding to any hierarchy sub-link into corresponding long strings to solve the above-mentioned problem of "confusion".
On the one hand, the separation character strings contained in the sub-links at each level in the original URL link are encoded into long character strings with relatively longer character lengths, so that the target URL link obtained through encoding is longer. On the other hand, each encoded separator string may be the same separator string, which results in the encoded target URL link containing a large number of repeated encoded content. Because the link length of the target URL obtained by coding is increased and the repeated content is more, the generated two-dimensional code is more complicated.
Therefore, by configuring the mapping relationship between the long character string and the short character string in advance, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and the complexity of the target URL link are effectively reduced, and the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. When the two-dimensional code is identified, the original URL link is restored according to the preset mapping relation.
Drawings
Fig. 1 is a flowchart of a two-dimensional code generation method according to an exemplary embodiment.
Fig. 2 is a flowchart of a two-dimensional code recognition method according to an exemplary embodiment.
Fig. 3A is a flowchart of another two-dimensional code generation method according to an exemplary embodiment.
Fig. 3B is a schematic diagram of a two-dimensional code provided in an exemplary embodiment.
Fig. 4 is a flowchart of another two-dimensional code recognition method according to an exemplary embodiment.
Fig. 5 is a schematic structural diagram of an electronic device according to an exemplary embodiment.
Fig. 6 is a block diagram of a two-dimensional code generating apparatus according to an exemplary embodiment.
Fig. 7 is a schematic structural diagram of another electronic device according to an exemplary embodiment.
Fig. 8 is a block diagram of another two-dimensional code generation apparatus according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of one or more embodiments of the specification, as detailed in the claims which follow.
It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described herein. In some other embodiments, the method may include more or fewer steps than those described herein. Moreover, a single step described in this specification may be broken down into multiple steps for description in other embodiments; multiple steps described in this specification may be combined into a single step in other embodiments.
Referring to fig. 1, fig. 1 is a flowchart of a two-dimensional code generation method according to an exemplary embodiment. The method is applied to two-dimensional code generation equipment and can comprise the following steps:
102, obtaining a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of the sub-links into a corresponding long character string.
In this embodiment, the original URL link includes multiple levels of nested child links, the child links at each level are distinguished by a separation string, and when the child link content itself also includes a separation string (i.e., the separation string belongs to at least a part of the content of the child link), the separation string included in the child link content itself has a "confusion" problem, and the child links at each level cannot be correctly identified based on the separation string. Therefore, the URL encoding algorithm is adopted to encode the separator strings corresponding to any hierarchy sub-link into corresponding long strings to solve the above-mentioned problem of "confusion".
On the one hand, the separation character strings contained in the sub-links at each level in the original URL link are encoded into long character strings with relatively longer character lengths, so that the target URL link obtained through encoding is longer. On the other hand, each encoded separator string may be the same separator string, which results in the encoded target URL link containing a large number of repeated encoded content. Because the link length of the target URL obtained by coding is increased and the repeated content is more, the generated two-dimensional code is more complicated. Therefore, by configuring the mapping relationship between the long character string and the short character string in advance, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and the complexity of the target URL link are effectively reduced, and the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. When the two-dimensional code is identified, the original URL link is restored according to the preset mapping relation.
Further, the original URL link contains multiple levels of nested child links, and a separation character string in the original URL link is used to mark the content of each level of child links, so that the child links of each level can be distinguished by the separation character string. For example, a character string indicating the start position and the end position of the sub link may be used as the separation character string. However, since a uniform separation character string is used as a basis for identification, when the sub-link content itself also includes a separation character string (i.e., the separation character string belongs to at least a part of the content of the sub-link), the separation character string included in the sub-link content itself has a problem of "confusion", and the sub-link at each level cannot be correctly identified based on the separation character string.
Aiming at the problem, a URL (Uniform resource locator) encoding algorithm is adopted to encode the separation character string corresponding to any hierarchy sublink into a corresponding long character string, the encoding times of any hierarchy sublink are equal to the nesting hierarchy level to which the hierarchy sublink belongs, and the encoded long character string is still used as the separation character string corresponding to the hierarchy sublink in the next encoding process. Based on the above URL encoding method, the encoding frequency of a sub-link at any level is one more than the encoding frequency of a sub-link at the previous level, and thus the partition character string included in the content of the sub-link at any level is a long character string obtained by URL encoding the partition character string corresponding to the sub-link at the previous level. In other words, the sub-links of each level correspond to different separation strings, and the separation strings between the sub-links of adjacent levels are in a "derivative" relationship, so that the problem of "confusion" does not exist. Therefore, the sub-links of each level can still be distinguished from each other by the separation character string corresponding to the nested level.
For example, in the http protocol, the transmission format of the parameter is "key value", and when a plurality of parameters need to be transmitted, the key value pair may be segmented using the "&" symbol. For example, a URL link is "https:// www.alipay.com? The name1 value1& name2 value2 ", then the server resolving the URL link segments each parameter according to" & "and then segments the parameter value with" & ". In other words, "&" and "═ are uniformly employed as the separator character strings (of course, the separator character strings can be flexibly selected depending on the specific contents of the URL link).
However, as network traffic gets more complex, the URL links need to contain multiple levels of nested child links. The above partitioning method has a problem of "confusion" when the URL link contains multiple levels of nested child links. For example, the original URL link is:
https://www.alipay.com?thirdParam=https://www.baidu.com?param1=1&param2=https://www.taobao.com?subP1=c&subP2=d。
wherein the parameter "thirdParam" comprises two levels of nested sublinks: level 1 child link is "https:// www.baidu.com? param1 ═ 1& param2 ═ 1 "; the value of parameter param2 (at the same level as parameter param 1) is level 2 sublinked: https:// www.taobao.com? subP1 ═ c & subP2 ═ d. With the above-described partitioning method, the sub-p 1 in the sub-link at the 2 nd level is c & sub-p 2 d, which has a confusion problem and cannot be recognized as the value of the parameter param2, but may be recognized as another parameter at the same level as the parameter param1 being 1 and the parameter param 2.
Therefore, the original URL link may be URL encoded using a URL encoding algorithm to solve the "confusion" problem. Specifically, a URL encoding algorithm is adopted to encode the separation character string corresponding to any hierarchy sublink into a corresponding long character string, the encoding frequency of any hierarchy sublink is equal to the nesting hierarchy level to which the hierarchy sublink belongs, and the encoded long character string is still used as the separation character string corresponding to the hierarchy sublink in the next encoding process. In other words, it can be understood that the sub-link of the level of several needs to be encoded several times. The length of the long character string obtained by encoding the divided character string is longer than the length of the divided character string.
For the above example, taking the UrlEncode as an example, the separating character string selected for the original URL link and the corresponding long character string are shown in table 1:
separating character strings Encoding a long character string obtained 1 time Encoding a long string of characters obtained 2 times
:// %3a%2f%2f %253a%252f%252f
%3f %253f
%3d %253d
& %26 %2526
…… …… ……
TABLE 1
According to the encoding mode recorded in table 1, URL encoding is performed for 1 time on the 1 st level child link to obtain: https% 3 a% 2 f% 2 fwwww.baidu.com% 3fparam 1% 3d 1% 26param 2% 3 d. For the 2 nd level sub-link, 2 times of URL encoding are required, wherein the result of 1 st URL encoding is: https% 3 a% 2 f% 2 fwwww.taobao.com% 3fsubP 1% 3 dc% 26subP 2% 3 dd; and carrying out URL encoding for the 2 nd time on the basis of the encoding result, wherein the obtained encoding result is as follows: https% 253 a% 252 f% 252 fwwww.taobao.com% 253fsubP 1% 253 dc% 2526subP 2% 253 dd.
Therefore, the target URL link obtained by URL encoding the original URL link is: https:// www.alipay.com? thirdParam 3 a% 2 f% 2 fww.baidu.com% 3fparam 1% 3d 1% 26param 2% 3 dhttps% 253 a% 252 f% 252 fww.taobao.com% 253fsubP 1% 253 dc% 2526subP 2% 253 dd.
When decoding the URL link of destination (UrlDecode decoding), the result obtained by the 1 st decoding is:
https:// www.alipay.com? thirdParam ═ https:// www.baidu.com? param1 ═ 1& param2 ═ https% 3 a% 2 f% 2 fww.taobao.com% 3fsubP 1% 3 dc% 26subP 2% 3 dd. Thus, the level 1 sublink is "https:// www.baidu.com? param1 ═ 1& param2 ═ 1 "; the value of parameter param2 is level 2 child link. Further, the 2 nd decoding is performed, and the obtained result is:
https:// www.alipay.com? thirdParam ═ https:// www.baidu.com? param1 ═ 1& param2 ═ https:// www.taobao.com? subP1 ═ c & subP2 ═ d. The parameter param2 thus available has a value https:// www.taobao.com? subP1 ═ c & subP2 ═ d.
In this embodiment, in one case, a user may first perform URL coding on an original URL link through a URL link coding device to obtain a corresponding target URL link, and then input the target URL link in a two-dimensional code generating device, so that the two-dimensional code generating device generates a two-dimensional code. Then, the two-dimensional code generating apparatus may detect the content input within the input area of the URL link and regard the detected content as a target URL link. In another case, the URL encoding function may be integrated into the two-dimensional code generating device, that is, the two-dimensional code generating device first obtains the original URL link (for example, the original URL link may be input to the two-dimensional code generating device by a user), and then encodes each level of sub-links in the original URL link by using a URL encoding algorithm to obtain the target URL link.
And 104, replacing the long character string contained in the target URL link with a short character string according to a preset mapping relation between the long character string and the short character string to obtain a short URL link corresponding to the target URL link.
In this embodiment, on one hand, the separation character strings included in the sub-links at each level in the original URL link are encoded into long character strings with relatively longer character lengths, and the longer the encoding times are, the longer the long character strings generated after encoding is, which results in longer encoded target URL links. On the other hand, each encoded separator string may be the same separator string, which results in the encoded target URL link containing a large number of repeated encoded content. Because the link length of the target URL obtained by coding is increased and the repeated content is more, the generated two-dimensional code is more complicated.
For the problem, the mapping relation between the long character string and the short character string can be configured in advance, so that the long character string contained in the target URL link obtained by encoding is replaced by the short character string based on the mapping relation, the length and the complexity of the target URL link are effectively reduced, the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. When the two-dimensional code is identified, the original URL link is restored according to the preset mapping relation. The long character string obtained by encoding any separating character string by using a URL encoding algorithm is in one-to-one correspondence with any separating character string, and the long character string and the short character string in the mapping relationship are in one-to-one correspondence.
In the present embodiment, the mapping relationship may be established based on the frequency of occurrence of each long character string. In particular, a link set may be obtained that contains a number of sample URL links that include multiple levels of nested child links and are encoded using a URL encoding algorithm. For example, a number of original URL links including multiple levels of nested child links may be obtained and URL-encoded, so that the encoded result (the link obtained by URL-encoding the original URL link is a sample URL link) is used as the link set. Then, the occurrence frequency of each long character string in the link set is counted, and the mapping relation between each long character string and each short character string is established according to the occurrence frequency. The length of the short character string corresponding to any long character string is in negative correlation with the appearance frequency of any long character string. Therefore, by establishing the mapping relation based on the occurrence frequency, the length of the finally obtained short URL link can be made shortest as the length of the corresponding short character string is shorter in the long character string with higher occurrence probability in the link after the original URL link is subjected to URL coding, and the two-dimensional code generated based on the short URL link is correspondingly simplest. For example, Huffman coding (also called Huffman coding) may be used to construct a codeword with the shortest average length of the anomeric word heads according to the occurrence probability of the characters.
And 106, generating a two-dimensional code based on the short URL link.
In this embodiment, any algorithm for generating a two-dimensional code may be used to generate a corresponding two-dimensional code based on a short URL link, which is not limited by one or more embodiments of the present specification. For example, the type of the two-dimensional Code may be DataMatrix, Maxi Code, Aztec, QR Code, Vericode, PDF417, Ultracode, Code 49, Code 16K, etc., and the algorithm for generating the two-dimensional Code is different for different types of two-dimensional codes. For example, a two-dimensional code generator may be used to select the type of two-dimensional code to be generated and the corresponding algorithm.
Correspondingly, aiming at the two-dimension code generation method, the specification also provides a two-dimension code identification method. As shown in fig. 2, the method is applied to a two-dimensional code recognition device, and may include the following steps:
step 202, analyzing the target two-dimensional code to obtain a short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link including multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string.
In this embodiment, the process of obtaining the target URL link by URL encoding the original URL link and the process of establishing the mapping relationship refer to the corresponding parts of the embodiment shown in fig. 2, which are not described herein again.
Step 204, obtaining a reduction result aiming at the short URL link, and taking the reduction result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
In this embodiment, in one case, since the mapping relationship is fixed (in a one-to-one correspondence relationship) and no calculation is required to complete the conversion between the long character string and the short character string, the mapping relationship can be configured locally on the two-dimensional code identification device, the mapping relationship occupies a small storage space, and the mapping relationship is used to complete the conversion between the long character string and the short character string, so that the operation occupies a small processing resource. Therefore, the short character strings included in the short URL links obtained by analyzing the target two-dimensional code can be replaced with long character strings according to the mapping relationship configured locally.
In another case, the mapping relationship may be configured in the recovery server, so that the recovery server uses the mapping relationship to complete the conversion between the long character string and the short character string, thereby further reducing the occupation of the storage space and the processing resource of the two-dimensional code identification device. Based on this, after the two-dimensional code identification device analyzes the target two-dimensional code to obtain the short URL link, the two-dimensional code identification device can send the short URL link to the reduction server, so that the reduction server replaces the short character string contained in the short URL link with the long character string according to the mapping relation configured locally, and the two-dimensional code identification device can receive the replaced URL link returned by the reduction server to serve as the reduction result of the short URL link.
In this embodiment, a short string identifier may be added to the short string to indicate the identity of the short string, so as to distinguish the short string from other strings, which is beneficial to improving the recovery efficiency. For example, a character or character string not included in the target URL link may be selected as the short string identification. Therefore, in the restoration process of replacing the short character string with the long character string by using the mapping relation, the short character string in the short URL link is identified according to the short character string identification, and then the identified short character string is replaced with the long character string according to the mapping relation. The specific form of the short string identifier may be flexibly set according to specific situations, and one or more embodiments of the present specification do not limit this.
As can be seen from the above embodiments, the original URL link includes multiple levels of nested child links, the child links at different levels are distinguished by a separation character string, and when the child link content itself also includes a separation character string (i.e., the separation character string belongs to at least a part of the content of the child link), the separation character string included in the child link content itself has a problem of "confusion", and the child links at different levels cannot be correctly identified based on the separation character string. Therefore, the URL encoding algorithm is adopted to encode the separation character string corresponding to any hierarchy sub-link into a corresponding long character string, the encoding frequency of any hierarchy sub-link is equal to the nesting level number of the hierarchy sub-link, and the encoded long character string is still used as the separation character string corresponding to the hierarchy sub-link in the next encoding process. Based on the above URL encoding method, the encoding frequency of a sub-link at any level is one more than the encoding frequency of a sub-link at the previous level, and thus the partition character string included in the content of the sub-link at any level is a long character string obtained by URL encoding the partition character string corresponding to the sub-link at the previous level. In other words, the sub-links of each level correspond to different separation strings, and the separation strings between the sub-links of adjacent levels are in a "derivative" relationship, so that the problem of "confusion" does not exist. Therefore, the sub-links of each level can still be distinguished from each other by the separation character string corresponding to the nested level.
On one hand, the separation character strings contained in each level of sub-links in the original URL link are encoded into long character strings with relatively longer character lengths, and the longer the encoding times are, the longer the long character strings generated after encoding are, so that the target URL link obtained through encoding is longer. On the other hand, each encoded separator string may be the same separator string, which results in the encoded target URL link containing a large number of repeated encoded content. Because the link length of the target URL obtained by coding is increased and the repeated content is more, the generated two-dimensional code is more complicated.
Therefore, by configuring the mapping relationship between the long character string and the short character string in advance, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and the complexity of the target URL link are effectively reduced, and the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. When the two-dimensional code is identified, the original URL link is restored according to the preset mapping relation.
For convenience of understanding, the two-dimensional code generation and recognition scheme of the present specification will be described in detail below with reference to scenes and examples.
Referring to fig. 3A, fig. 3A is a flowchart of another two-dimensional code generation method according to an exemplary embodiment. The method is applied to two-dimensional code generation equipment and can comprise the following steps:
step 302, obtain the original URL link.
In this embodiment, a description will be given taking an example in which a function of encoding a URL is integrated in a two-dimensional code generating apparatus. The user can input an original URL link to the two-dimensional code generation equipment and indicate the nesting relation among all levels of sub-links, and then the two-dimensional code generation equipment can respectively carry out URL coding on all levels of sub-links in the original URL link by adopting a URL coding algorithm.
Step 304, URL encoding is performed.
For example, the original URL link is:
example:// testapi/openapp? app 888888& update sync & version 0.1.1111111.11& url/www/index html? first & second ═ 0} & third { [ 1} & forth ═ 1& fast { [ true & ex Params { "alscale ext" { "channel key": 2} "," cityId ": 3}", "storeId": 4} "," source From ": 5}" }. Wherein the level 1 sublinks are:
html? first & second ═ {0} & third ═ 1} & forth ═ 1& fast ═ true & exP arms ═ f. Level 2 sublinks are:
{"alscItemExt":{"channelKey":"{2}","cityId":"{3}","storeId":"{4}","sourceFro m":"{5}"}}。
taking the UrlEncode as an example, the 'indicates the starting position of the object to be uploaded, and the' indicates the ending position of the object to be uploaded. Therefore, the above character strings can be selected as the separating character strings, and the specific selection manner can be flexibly set according to the content of the original URL, which is only an example. Assume that the separator strings and their corresponding long strings (case-free) selected for the original URL link are shown in table 2:
separating character strings Encoding a long character string obtained 1 time Encoding a long string of characters obtained 2 times
={" %3d%7b%22 %3D%257B%2522
":{" %22%3a%7b%22 %2522%253a%257b%2522
"}} %22%7d%7d %2522%257d%257d
":{" %22%3a%7b%22 %2522%253a%257b%2522
":}" %22%3a%7d%22 %2522%253a%257d%2522
{" %7b%22 %257b%2522
":" %22%3a%22 %2522%253a%2522
"" %22%2c%22 %2522%252c%2522
& %26 %2526
%3d %253d
/ %2f %252f
…… …… ……
TABLE 2
Then, 1 URL encoding for level 1 child link results in:
%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams%3D。
and (3) carrying out 1-time URL encoding on the 2 nd level sub-link to obtain:
%7B%22alscItemExt%22%3A%7B%22channelKey%22%3A%22{2}%22%2C%22cityId%22%3A%22{3}%22%2C%22storeId%22%3A%22{4}%22%2C%22sourceFrom%22%3A%22{5}%22%7D%7D。
and 2 times of URL encoding is carried out on the 2 nd level sub-link to obtain:
%257B%2522alscItemExt%2522%253A%257B%2522channelKey%2522%253A%2522{2}%2522%252C%2522cityId%2522%253A%2522{3}%2522%252C%2522storeId%2522%253A%2522{4}%2522%252C%2522sourceFrom%2522%253A%2522{5}%2522%257D%257D。
to sum up, the destination URL link obtained by URL encoding the original URL is:
example://testapi/openapp?app=888888&update=sync&version=0.1.1111111.11&url=%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams%3D%257B%2522alscItemExt%2522%253A%257B%2522channelKey%2522%253A%2522{2}%2522%252C%2522cityId%2522%253A%2522{3}%2522%252C%2522storeId%2522%253A%2522{4}%2522%252C%2522sourceFrom%2522%253A%2522{5}%2522%257D%257D。
step 306, replacing the long character string with the numeric mapping code.
For example, assume the form of a short string is-n-; wherein, the character string is short character string identification, and the middle number n corresponds to each long character string in turn. For example, the mapping obtained in the manner of the "frequency of occurrence" is shown in table 3:
Figure BDA0002274840380000171
TABLE 3
Then, the short URL link obtained by replacing the long string in the target URL link according to table 3 is:
example://testapi/openapp?app=888888&update=sync&version=0.1.1111111.11&url=%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams~3~alscItemExt~4~channelKey~1~{2}~2~cityId~1~{3}~2~storeId~1~{4}~2~sourceFrom~1~{5}~0~。
and 308, generating the two-dimensional code based on the short URL link.
In this embodiment, any algorithm for generating a two-dimensional code may be used to generate a corresponding two-dimensional code based on a short URL link, which is not limited by one or more embodiments of the present specification. For example, the type of the two-dimensional Code may be DataMatrix, Maxi Code, Aztec, QR Code, Vericode, PDF417, Ultracode, Code 49, Code 16K, etc., and the algorithm for generating the two-dimensional Code is different for different types of two-dimensional codes. For example, a two-dimensional code generator may be used to select the type of two-dimensional code to be generated and the corresponding algorithm.
As shown in fig. 3B, the two-dimensional code a is a two-dimensional code generated based on an original URL link, and the two-dimensional code B is a two-dimensional code generated based on a short URL link. The mapping relation between the long character string and the short character string is configured in advance, the long character string contained in the target URL link obtained through coding can be replaced by the short character string, so that the length and the complexity of the target URL link are effectively reduced, and the two-dimensional code B generated based on the short URL link obtained after replacement is relatively simpler than the two-dimensional code A, and the efficiency of identifying the two-dimensional code is improved. When the two-dimensional code is identified, the original URL link is restored according to the preset mapping relation.
Correspondingly, please refer to fig. 4, where fig. 4 is a flowchart of another two-dimensional code recognition method according to an exemplary embodiment. The method is applied to two-dimensional code identification equipment and can comprise the following steps:
step 402, scanning the two-dimensional code B.
In this embodiment, the two-dimensional code recognition device may be a mobile phone, a tablet computer, a two-dimensional code scanner, and the like, which is not limited in this description by one or more embodiments. The following description will be given taking an example in which the mobile phone 41 scans the two-dimensional code B to access a network resource.
And step 404, analyzing the two-dimension code B to obtain a short URL link.
And 406, restoring according to the digital mapping code to obtain the destination URL link.
For the above example, the mobile phone 41 is configured with the number mapping code shown in table 3 locally, and then the mobile phone 41 may replace the short character string included in the short URL link obtained by analyzing the two-dimensional code B with the long character string according to the locally configured number mapping code, so as to obtain the destination URL link corresponding to the original URL link in the embodiment shown in fig. 3A, that is, the reverse process of the step 306, which is not described herein again.
Step 408, the network resource is accessed to the server 42 according to the original URL link.
Accepting from the above example, the destination URL links available to the handset 41 are:
example:// testapi/openapp? app 888888& update ═ sync & version [% 0.1.1111111.11& url [% 2 fww% ] 2Findex. html% 3 Ffirst% 3 Dtrue% 26 second% 3D {0 }% 26 third% {1 }% 26for th% 3D 1% 26f after h% 3 Dtrue% 26 exParams% 3D% 257B 2522 instead% 2522% 253A% 2522B% 2522channel key% 2522% 253A% {2 }% 2522% 252C% 2522 cityId% 253A% { 2523 }% 2522 } 2522522% 252C% 2522 storeId% 2522% 252257D% 2522 } 252257% 2522 } 2522{ 252C% 252% sourceId% 2% A% 2525 { 2522 } 2522% 2522 } 2522D }% 2522. Further, the mobile phone 41 performs UrlDecode decoding on the destination URL to access the corresponding network resource to the server 42 according to the decoded URL link.
Corresponding to the embodiment of the method, the specification further provides an embodiment of a two-dimensional code generation device.
The two-dimensional code generation apparatus of the present specification may be applied to an electronic device. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a logical device, the device is formed by reading, by a processor of the electronic device where the device is located, a corresponding computer program instruction in the nonvolatile memory into the memory for operation.
From a hardware level, please refer to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an exemplary embodiment. As shown in fig. 5, at the hardware level, the apparatus includes a processor 502, an internal bus 504, a network interface 506, a memory 508, and a non-volatile memory 510, although it may also include hardware required for other services. The processor 502 reads a corresponding computer program from the non-volatile memory 510 into the memory 508 and then runs the computer program, thereby forming a two-dimensional code generating apparatus on a logical level. Of course, besides software implementation, the one or more embodiments in this specification do not exclude other implementations, such as logic devices or combinations of software and hardware, and so on, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Referring to fig. 6, in a software implementation, the two-dimensional code generating apparatus may include:
the acquisition unit 61 is configured to acquire a target URL link, where the target URL link is obtained by encoding an original URL link including multiple levels of nested child links by using a URL encoding algorithm, and the URL encoding algorithm is configured to encode a separation character string corresponding to a child link at any level into a corresponding long character string;
a replacing unit 62, configured to replace the long character string included in the target URL link with a short character string according to a mapping relationship between a pre-configured long character string and a pre-configured short character string, so as to obtain a short URL link corresponding to the target URL link;
and a generating unit 63 for generating a two-dimensional code based on the short URL link.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Optionally, the obtaining unit 61 is specifically configured to:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; alternatively, the first and second electrodes may be,
acquiring the original URL link;
and respectively encoding each level of sub-links in the original URL link by adopting the URL encoding algorithm to obtain the target URL link.
Optionally, a one-to-one correspondence relationship is formed between the long character string obtained by encoding any one of the separation character strings by using the URL encoding algorithm and the any one of the separation character strings; and the long character strings and the short character strings in the mapping relation are in one-to-one correspondence.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
Corresponding to the embodiment of the method, the specification also provides an embodiment of a two-dimensional code recognition device.
The two-dimensional code recognition device of the present specification can be applied to electronic devices. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a logical device, the device is formed by reading, by a processor of the electronic device where the device is located, a corresponding computer program instruction in the nonvolatile memory into the memory for operation.
Referring to fig. 7, fig. 7 is a schematic block diagram of an electronic device according to an exemplary embodiment. As shown in fig. 7, at the hardware level, the apparatus includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile storage 710, although it may also include hardware required for other services. The processor 702 reads a corresponding computer program from the non-volatile memory 710 into the memory 708 and then runs the computer program to form a two-dimensional code recognition apparatus on a logic level. Of course, besides software implementation, the one or more embodiments in this specification do not exclude other implementations, such as logic devices or combinations of software and hardware, and so on, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Referring to fig. 8, in a software implementation, the two-dimensional code recognition apparatus may include:
an analyzing unit 81 that analyzes the target two-dimensional code to obtain a short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link comprising multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string;
an obtaining unit 82 that obtains a reduction result for the short URL link, and takes the reduction result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
Optionally, the long character string obtained by encoding the sub-link at any level by using the URL encoding algorithm is used as a separation character string corresponding to the sub-link at the level in the next encoding process, the separation character string is used to mark the content of the sub-link at each level, and the encoding frequency for the sub-link at any level is equal to the number of nested levels to which the sub-link at the level belongs.
Alternatively to this, the first and second parts may,
the mapping relation is configured locally; the obtaining unit 82 is specifically configured to: replacing short character strings contained in the short URL links with long character strings according to the locally configured mapping relation; alternatively, the first and second electrodes may be,
the obtaining unit 82 is specifically configured to: sending the short URL link to a reduction server so that the reduction server replaces a short character string contained in the short URL link with a long character string according to the mapping relation; and receiving the replaced URL link returned by the restoring server as the restoring result of the short URL link.
Optionally, the short character string in the mapping relationship includes a short character string identifier; obtaining a reduction result of the short URL link by the following method:
identifying a short string in the short URL link according to the short string identification,
and replacing the identified short character string with a long character string according to the mapping relation.
Optionally, the mapping relationship is obtained by the following method:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments herein. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
The above description is only for the purpose of illustrating the preferred embodiments of the one or more embodiments of the present disclosure, and is not intended to limit the scope of the one or more embodiments of the present disclosure, and any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the one or more embodiments of the present disclosure should be included in the scope of the one or more embodiments of the present disclosure.

Claims (10)

1. A two-dimensional code generation method is characterized by comprising the following steps:
acquiring a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of the sub-links into a corresponding long character string;
replacing the long character string contained in the target URL link with a short character string according to a preset mapping relation between the long character string and the short character string so as to obtain a short URL link corresponding to the target URL link;
and generating a two-dimensional code based on the short URL link.
2. The method according to claim 1, wherein a long character string obtained by encoding any one level of sub-link by using the URL encoding algorithm is used as a separation character string corresponding to the level of sub-link in a next encoding process, the separation character string is used for marking the content of each level of sub-link, and the number of encoding times for any one level of sub-link is equal to the number of nested levels to which the level of sub-link belongs.
3. The method of claim 1, wherein the mapping is obtained by:
obtaining a link set containing a number of sample URL links, wherein the sample URL links comprise multiple levels of nested sub-links and are encoded by the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is in negative correlation with the occurrence frequency of any long character string.
4. A two-dimensional code recognition method is characterized by comprising the following steps:
analyzing the target two-dimensional code to obtain a short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link comprising multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string;
acquiring a reduction result aiming at the short URL link, and taking the reduction result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
5. The method according to claim 4, wherein a long character string obtained by encoding any one level of sub-link by using the URL encoding algorithm is used as a separation character string corresponding to the level of sub-link in the next encoding process, the separation character string is used for marking the content of each level of sub-link, and the encoding times for any level of sub-link are equal to the number of nested levels to which the level of sub-link belongs.
6. The method of claim 4,
the mapping relation is configured locally; the obtaining of the restoration result for the short URL link includes: replacing short character strings contained in the short URL links with long character strings according to the locally configured mapping relation; alternatively, the first and second electrodes may be,
the obtaining of the restoration result for the short URL link includes: sending the short URL link to a reduction server so that the reduction server replaces a short character string contained in the short URL link with a long character string according to the mapping relation; and receiving the replaced URL link returned by the restoring server as the restoring result of the short URL link.
7. A two-dimensional code generation device, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target URL link, the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level of sub-links into a corresponding long character string;
the replacing unit is used for replacing the long character string contained in the target URL link with the short character string according to the mapping relation between the preset long character string and the preset short character string so as to obtain the short URL link corresponding to the target URL link;
and the generating unit is used for generating a two-dimensional code based on the short URL link.
8. A two-dimensional code recognition device, comprising:
the analysis unit is used for analyzing the target two-dimensional code to obtain the short URL link; the short URL link is obtained by replacing a long character string contained in a target URL link with a short character string according to a preset mapping relation between the long character string and the short character string, the target URL link is obtained by encoding an original URL link of a sub-link comprising multi-level nesting by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to the sub-link of any level into a corresponding long character string;
an acquisition unit that acquires a restoration result for the short URL link, and takes the restoration result as a target URL link corresponding to the target two-dimensional code; and replacing the short character string contained in the short URL link with a long character string according to the mapping relation to obtain the reduction result.
9. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of any one of claims 1-3 by executing the executable instructions.
10. A computer-readable storage medium having stored thereon computer instructions, which, when executed by a processor, carry out the steps of the method according to any one of claims 1-3.
CN201911118805.5A 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium Active CN111027656B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911118805.5A CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911118805.5A CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111027656A true CN111027656A (en) 2020-04-17
CN111027656B CN111027656B (en) 2023-04-28

Family

ID=70200353

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911118805.5A Active CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111027656B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111695051A (en) * 2020-05-06 2020-09-22 支付宝(杭州)信息技术有限公司 Page access method and device based on code scanning, electronic equipment and storage medium
CN112149445A (en) * 2020-10-22 2020-12-29 北京京东振世信息技术有限公司 Bar code processing method, device, equipment and storage medium
CN112380464A (en) * 2020-11-10 2021-02-19 中国平安人寿保险股份有限公司 Short link generation method and related equipment
CN113312622A (en) * 2021-06-09 2021-08-27 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Method and device for detecting URL (Uniform resource locator)
CN113468855A (en) * 2021-06-30 2021-10-01 北京达佳互联信息技术有限公司 Data processing method, device, server and storage medium
CN113761406A (en) * 2021-09-03 2021-12-07 深圳市丰巢网络技术有限公司 Intelligent cabinet two-dimensional code short-chain generation method, device, medium and electronic equipment
CN114358230A (en) * 2021-08-17 2022-04-15 深圳市神州路路通网络科技有限公司 Method, system, equipment and storage medium for controlling vehicle to enter and exit parking lot

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1078928A (en) * 1996-07-08 1998-03-24 D & I Syst Kk Internet access method and system and storage medium storing internet access processing
CN102142033A (en) * 2010-05-20 2011-08-03 百度在线网络技术(北京)有限公司 Method and device for providing relative sub-link information in search result
US20110295990A1 (en) * 2010-06-01 2011-12-01 Meltwater News International Holdings, GmbH Method and Apparatus for Embedding Information in a Short URL
CN103259852A (en) * 2013-04-19 2013-08-21 山东电力集团公司 Distributed type data splicing method based on URI
CN104966218A (en) * 2015-07-09 2015-10-07 浙江工商大学 Two-dimension code advertisement putting and channel evaluating method based on dual URLs (uniform resource locators)
CN106375189A (en) * 2016-08-31 2017-02-01 北京炎黄新星网络科技有限公司 Long and short link switching method and system
CN106933871A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and short linked server
CN108228710A (en) * 2017-11-30 2018-06-29 中国科学院信息工程研究所 A kind of segmenting method and device for URL
US20190130044A1 (en) * 2017-11-02 2019-05-02 Brother Kogyo Kabushiki Kaisha Non-Transitory Storage Medium Storing Instructions Readable by Information Processing Apparatus, And Two-Dimensional-Code Creating System

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1078928A (en) * 1996-07-08 1998-03-24 D & I Syst Kk Internet access method and system and storage medium storing internet access processing
CN102142033A (en) * 2010-05-20 2011-08-03 百度在线网络技术(北京)有限公司 Method and device for providing relative sub-link information in search result
US20110295990A1 (en) * 2010-06-01 2011-12-01 Meltwater News International Holdings, GmbH Method and Apparatus for Embedding Information in a Short URL
CN103259852A (en) * 2013-04-19 2013-08-21 山东电力集团公司 Distributed type data splicing method based on URI
CN104966218A (en) * 2015-07-09 2015-10-07 浙江工商大学 Two-dimension code advertisement putting and channel evaluating method based on dual URLs (uniform resource locators)
CN106933871A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and short linked server
CN106375189A (en) * 2016-08-31 2017-02-01 北京炎黄新星网络科技有限公司 Long and short link switching method and system
US20190130044A1 (en) * 2017-11-02 2019-05-02 Brother Kogyo Kabushiki Kaisha Non-Transitory Storage Medium Storing Instructions Readable by Information Processing Apparatus, And Two-Dimensional-Code Creating System
CN108228710A (en) * 2017-11-30 2018-06-29 中国科学院信息工程研究所 A kind of segmenting method and device for URL

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111695051A (en) * 2020-05-06 2020-09-22 支付宝(杭州)信息技术有限公司 Page access method and device based on code scanning, electronic equipment and storage medium
CN111695051B (en) * 2020-05-06 2022-03-25 支付宝(杭州)信息技术有限公司 Page access method and device based on code scanning, electronic equipment and storage medium
CN112149445A (en) * 2020-10-22 2020-12-29 北京京东振世信息技术有限公司 Bar code processing method, device, equipment and storage medium
CN112380464A (en) * 2020-11-10 2021-02-19 中国平安人寿保险股份有限公司 Short link generation method and related equipment
CN112380464B (en) * 2020-11-10 2023-07-28 中国平安人寿保险股份有限公司 Short link generation method and related equipment
CN113312622A (en) * 2021-06-09 2021-08-27 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Method and device for detecting URL (Uniform resource locator)
CN113468855A (en) * 2021-06-30 2021-10-01 北京达佳互联信息技术有限公司 Data processing method, device, server and storage medium
CN114358230A (en) * 2021-08-17 2022-04-15 深圳市神州路路通网络科技有限公司 Method, system, equipment and storage medium for controlling vehicle to enter and exit parking lot
CN113761406A (en) * 2021-09-03 2021-12-07 深圳市丰巢网络技术有限公司 Intelligent cabinet two-dimensional code short-chain generation method, device, medium and electronic equipment

Also Published As

Publication number Publication date
CN111027656B (en) 2023-04-28

Similar Documents

Publication Publication Date Title
CN111027656A (en) Two-dimensional code generation and identification method and device, electronic equipment and storage medium
US11954930B2 (en) Decoding 1D-barcodes in digital capture systems
CN109840531B (en) Method and device for training multi-label classification model
US8550351B2 (en) Matrix type two-dimensional barcode decoding chip and decoding method thereof
CN111885000B (en) Network attack detection method, system and device based on graph neural network
CN102880849A (en) Two-dimension code recognition method and device
CN107919943B (en) Method and device for coding and decoding binary data
US10366315B1 (en) Generating a quick response (QR) grid associated with a digital document
CN111539502B (en) Anti-counterfeiting two-dimensional code generation method and device, server and storage medium
CN108491897B (en) Information identification method, server, client and system
CN112398838B (en) Authentication method, device, equipment and storage medium based on privacy protection
CN114448563B (en) Semantic code transmission method and electronic equipment
CN111510156A (en) Method for dynamically compressing and decompressing large file based on segmentation
CN114020272A (en) Serialized encoding and decoding methods and devices and electronic equipment
EP3047353A1 (en) Data-bearing medium
Ketcham et al. The evolutionary computation video watermarking using quick response code based on discrete multiwavelet transformation
CN110138501B (en) Decoding method and device for FM0 codes
CN107645665B (en) WebP entropy coding method and device
CN115499635A (en) Data compression processing method and device
Duda et al. Image-like 2d barcodes using generalizations of the Kuznetsov–Tsybakov problem
CN108734149B (en) Text data scanning method and device
CN108268920B (en) Method and device for generating bar code
CN112685404A (en) Encoding method applied to key tree, decoding method applied to key tree and electronic device
CN117058491B (en) Structured grid layout generation method and device based on recurrent neural network
CN110875744B (en) Coding method and device

Legal Events

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