Patent Description:
At present, bar codes have been widely used in different scenarios. For example, a terminal may directly display static information carried in a bar code by scanning the bar code, and the static information is reflected by numerical data, text description, or the like.

The static information displayed by the terminal is often numerical data or text description. For example, when the bar code carries a page link, the terminal scans the bar code through a built-in application. After the scanning, a to-be-accessed page link is displayed. The terminal then calls the page link through the application to obtain corresponding content information, namely, the content information corresponding to the page link cannot be directly displayed by scanning a two-dimensional code. That is, in the bar code display method provided in the related art, there is a problem that information carried in a bar code is relatively simple.

Document <CIT> relates to a method for the dynamic generation of quick response (QR) codes for secure communication to/from a mobile device, comprising: - receiving, in a mobile device executing a retail application, selection of a product or service by a user of the mobile device; generating, in the mobile device and based on the received user selection of the product or service, - a quick response (QR) code encoding identification of the selected product or service and identification of a user account of the user of the mobile device; displaying, by the mobile device, the generated QR code such that the QR code can be communicated to a retail kiosk associated with the retail application to allow the retail kiosk to provide the selected product or service from the retail kiosk in response to having read the displayed QR code. Time-sensitive encryption key may be used to ensure that the QR code can only be decrypted and used during a predetermined amount of time (say a <NUM> minute time period) following the generation of the QR code. Furthermore, document <CIT> discloses a method for providing context-aware functions in response to scanning a barcode, including determining that a barcode displayed on a mobile terminal has been scanned, retrieving metadata corresponding to the barcode when the barcode has been scanned, and triggering a context-aware action in the mobile terminal based on the barcode and/or the retrieved metadata.

For the foregoing problem, no effective solutions have been put forward so far.

Embodiments of this application provide methods and apparatuses for displaying and scanning a bar code, a storage medium, and an electronic device, according to the appended claims, to resolve at least the technical problem in the related art that information carried in a bar code is relatively simple.

In the embodiments of this application, a displayed programmable bar code is obtained by encoding target code, that is, information carried in the programmable bar code is the target code. Because the target code implements logical judgments and simple algorithms, the target code can implement corresponding logical functions, and expand a range of information carried in a bar code, so that the programmable bar code is applicable to more complex scenarios and has more abundant applications. Therefore, the embodiments of this application resolve the technical problem in the related art that information carried in a bar code is relatively simple.

The accompanying drawings described herein are used for providing further understanding for this application, and constitute a part of this application. Exemplary embodiments of this application and descriptions thereof are used for explaining this application and do not constitute an improper limitation to this application. In the accompanying drawings:.

To make a person skilled in the related art better understand solutions of this application, the following clearly and completely describes the technical solutions in embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are merely some rather than all of the embodiments of this application. All other embodiments obtained by a person skilled in the art based on the embodiments of this application without creative efforts shall fall within the protection scope of this application.

It should be noted that, in the specification, claims, and the foregoing accompanying drawings of this application, the terms "first", "second", and so on are intended to distinguish between similar objects rather than indicating a specific order or sequence. It is to be understood that the data termed in such a way are interchangeable in proper circumstances, so that the embodiments of this application described herein can be implemented in orders except the order illustrated or described herein. In addition, the terms "include", "comprise" and any other variants are intended to cover the non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those expressly listed steps or units, but may include other steps or units not expressly listed or inherent to such a process, method, product, or device.

According to an aspect of the embodiments of this application, a method for displaying a bar code is provided. In the embodiments of this application, a programmable bar code is a bar code that can be obtained through programming. The bar code may be a graphical identifier in which multiple black bars and blanks having different widths are arranged according to specific encoding rules to express a group of information. For example, the bar code may be specifically a bar shaped code or a two-dimensional code.

Optionally, in an optional implementation, the foregoing bar code display method may be applied to, but not limited to, an environment shown in <FIG>. As shown in <FIG>, description is made by using an example in which the bar code is a two-dimensional code. A terminal includes a computer <NUM> and a mobile terminal <NUM>. The computer <NUM> may obtain a programmable two-dimensional code encoding request through a server <NUM> or a network. After receiving the request, the computer <NUM> encodes target code in response to the request and obtains a target programmable two-dimensional code carrying the target code, the target code being used for executing a target logical function, and then the computer <NUM> displays the target programmable two-dimensional code on a display interface. The mobile terminal <NUM> may scan the target programmable two-dimensional code through its own application, to obtain the target code and run the target code, to implement a target logical function corresponding to the target code, and display, on the mobile terminal <NUM>, a result obtained by executing the target logical function.

The programmable bar code in the embodiments of this application is such a technology that by using the existing bar code encoding technology, the target code (a code character string compiled into a byte code or a customized proprietary programming language) is encoded into a programmable bar code to obtain a corresponding programmable bar code. During reading, a piece of target code is read through a corresponding programmable bar code decoding program. Then a target code program is run (for example, the target code program may be run by using a built-in dedicated virtual machine) to implement the corresponding logical function. Information carried in such a programmable bar code is the target code and is different from static text information carried in a conventional bar code. Because the target code implements logical judgments and simple algorithms, the target code can implement corresponding logical functions, and expand a range of information carried in a bar code, so that the programmable bar code is applicable to more complex scenarios and has more abundant applications. Therefore, the embodiments of this application resolve the technical problem in the related art that information carried in a bar code is relatively simple.

It should be noted that the foregoing terminal to which the embodiments of this application are applied may be a tablet computer, a notebook computer, a desktop PC, or the like, or a mobile terminal (mobile phone). The foregoing network may include, but is not limited to a wireless network or a wired network. The wireless network includes: Bluetooth, Wi-Fi, and another network implementing wireless communication. The foregoing wired network may include, but is not limited to, a wide area network, a metropolitan area network, and a local area network. The foregoing server may be used for data calculation and storage, such as a notebook computer or a PC.

According to an aspect of the embodiments of this application, a method for displaying a bar code is provided. As shown in <FIG>, the foregoing method for displaying the bar code may include the following steps:.

It should be noted that the foregoing programmable bar code may be applied to location positioning. For example, the target code carries information for calling corresponding positioning hardware, and then the programmable bar code carrying the target code is printed on a ticket, so that the positioning hardware is called by scanning the programmable bar code, to position, and content carried in the bar code may be the information for calling the corresponding positioning hardware. The foregoing programmable bar code may also be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). For example, personal information on a ticket is carried in target code, and then a programmable bar code carrying the target code is displayed on the ticket, so that content carried in the programmable bar code may also be the personal information on the ticket. It should be noted that the foregoing description is only two examples and this embodiment does not impose any limitation on this.

A displayed programmable bar code is obtained by encoding the target code, that is, information carried in the programmable bar code is the target code. Because the target code implements logical judgments and simple algorithms, the target code can implement various logical functions, and greatly expand a range of information carried in a bar code, so that the programmable bar code is applicable to more complex scenarios and has more abundant applications. Therefore, this embodiment of this application resolves the technical problem in the related art that information carried in a bar code is relatively simple.

It should be noted that the foregoing process of generating the target programmable bar code in response to the programmable bar code encoding request may include, but is not limited to, the following method: obtaining target code used as an input parameter of a target bar code encoding algorithm; and using a character string of the target code as the input parameter of the target bar code encoding algorithm according to the target bar code encoding algorithm, to obtain the target programmable bar code.

It should be noted that the target code may be obtained by using, but not limited to, the following method: a corresponding target parameter value is obtained according to a parameter input operation, for example, a corresponding identification card number is obtained according to identification information of a ticket purchaser entered by a ticket seller; and then the target parameter value may be used as a parameter in the target code, said parameter may be encrypted, and then the encrypted parameter is encoded to obtain the target code. For example, the foregoing identification card number is used as the parameter in the target code, and the identification card number is encoded to obtain the corresponding target code to protect the identification card number. For example, a logical function of a read permission to an identification card number may be set in the target code, or a validity period of running the code may be set in the target code.

It should be noted that the target code in this embodiment of this application is used for executing at least one of the following target logical functions:.

When the target code is used for executing the foregoing target logical function, the programmable bar code encoding request may be obtained by using, but not limited to the following method: receiving, by the terminal, a target request that is used for requesting to generate the target programmable bar code corresponding to a target location; and generating, by the terminal in response to the target request, the programmable bar code encoding request, the programmable bar code encoding request carrying an identifier used for positioning target hardware (for example, a GPS) at the target location. The generating a target programmable bar code in response to the programmable bar code encoding request includes: encoding, by the terminal, target code used for identifying target hardware in the terminal to obtain a target programmable bar code, so that after the bar code is read, the corresponding target code may be run to call the target hardware (for example, the GPS) to position the target location.

It should be noted that the foregoing target programmable bar code may be directly displayed on the terminal, or may be printed on a target medium. The foregoing target medium includes, but is not limited to the following: paper, cloth, plastic, glass, or the like.

In an optional solution, in this embodiment, the foregoing process of generating a target programmable bar code in response to the programmable bar code encoding request may be implemented by using, but not limited to the following method: obtaining target code; and executing a target bar code encoding algorithm to obtain the target programmable bar code, a character string of the target code being used as an input parameter of the target bar code encoding algorithm.

Description is specifically made with reference to the following examples. In this example and the following examples, description is made by using an example in which the bar code is a two-dimensional code. As shown in <FIG>, it is assumed that the target code has been written, and the character string of the foregoing target code is encoded by using a two-dimensional code encoder on the terminal <NUM>, to obtain a corresponding target programmable two-dimensional code. A target two-dimensional code encoding algorithm may be installed in the foregoing two-dimensional code encoder, and the target two-dimensional code encoding algorithm may be an existing two-dimensional code encoding algorithm.

As compared with the related art, in this embodiment of this application, the character string of the target code is used as the input parameter of the target bar code encoding algorithm. Text information is no longer used as the input parameter of the bar code encoding algorithm, and instead, the character string of the target code is used as the input parameter of the bar code encoding algorithm. Therefore, the foregoing programmable bar code carries the target code, and the bar code does not carry information but a piece of code, to avoid information leakage.

In an optional solution, in this embodiment, the foregoing target code is obtained by using, but not limited to the following method: obtaining a target parameter value in response to a parameter input operation; and generating the target code according to the target parameter value, a value of a parameter in the target code being the target parameter value.

Description is specifically made with reference to the following example. As shown in <FIG>, a ticket seller enters identification information of a ticket purchaser on a terminal <NUM>, and a control program editor sets a target parameter value of a target code model stored on the terminal to the identification information (for example, an identification card number) to generate corresponding target code. To reduce carrying capacity of a two-dimensional code, the foregoing program editor may be, but is not limited to, an integrated development environment (IDE for short). The foregoing target code model may be pre-compiled, and the ticket seller only needs to enter the target parameter value. The logical function that the target code model may implement is not limited. The logical function may be a permission of running the target code, or a permission to limit a validity period of running of the target code.

Through the foregoing embodiment, the target parameter value may be obtained according to a parameter input operation (for example, identification information is inputted) received by the terminal; and then, a value of a parameter in the target code is used as the target parameter value to generate the target code, so that a programmable bar code may be conveniently generated without restricting a compiling ability of a user who generates a bar code.

In an optional solution, the foregoing target code in this embodiment is used for executing at least one of the following target logical functions:.

In an optional solution, in this embodiment, the programmable bar code encoding request is obtained by using, but not limited to the following method: receiving, by a terminal, a target request that is used for requesting to generate a target programmable bar code corresponding to predetermined information (for example, the foregoing identification card information) of a target ticket, and generating, by the terminal in response to the target request, a programmable bar code encoding request carrying the predetermined information. The generating a target programmable bar code in response to the programmable bar code encoding request may be implemented by using, but not limited to the following method: encoding, by the terminal, the target code to obtain the target programmable bar code, a parameter of the target code including the predetermined information.

For example, the foregoing embodiment may be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). Description is made by using a train ticket as an example. Specific description is made with reference to the following example, as shown in <FIG>. When wanting to take a train to a place B, a tourist A needs to buy a train ticket to the place B, and the ticket may be bought online or manually through a counter. In this embodiment, description is made by using an example in which a ticket is bought manually through a counter. After getting information such as A's identification card or the like, a ticket seller C enters the identification number information of A in a terminal <NUM> to trigger the terminal to generate a programmable two-dimensional code encoding request, and add the identification card number information of A to an request. In response to the request, the terminal <NUM> adds the identification card number information of A to a piece of target code, then a terminal <NUM> encodes the target code to obtain a target programmable two-dimensional code, and then the target programmable two-dimensional code is printed on the train ticket. At last, A obtains the train ticket printed with the target programmable two-dimensional code. The operations executed by the terminal <NUM> and the terminal <NUM> may be executed on the same terminal.

In an optional solution, in this embodiment, the target code may be further used for executing the following target logical function: a first target logical function, used for allowing an account with a read permission, a device with the read permission, or a virtual machine with the read permission to run the target code. For example, the foregoing target code may include a permission to read a target programmable bar code, that is, only an account, a device, and the like having the foregoing permission can read the foregoing target programmable bar code, such as the two-dimensional code on the train ticket. Therefore even if the target code is decoded, only a device that has a read permission and that is in the hands of a ticket inspector can run the target code to read the identification card information in the target programmable two-dimensional code, to determine whether the passenger is the right person.

In an optional solution, in this embodiment, the programmable bar code encoding request is obtained by using, but not limited to the following method: receiving, by a terminal, a target request that is used for requesting to generate a target programmable bar code corresponding to a target location, and generating, by the terminal in response to the request, a programmable bar code encoding request carrying an identifier that is used for positioning target hardware (for example, the foregoing GPS) of the target location. Optionally, in this embodiment, the generating a target programmable bar code in response to the programmable bar code encoding request includes: encoding, by the terminal, the target code to obtain the target programmable bar code, the target code including a parameter used for identifying the target hardware in the terminal, and the target logical function being used for calling the target hardware to position the target location.

For example, the foregoing embodiment may be applied to location positioning. When the foregoing embodiment is applied to location positioning, description is made by using an example in which a Global Positioning System (GPS for short) in the terminal is called to position. When the terminal receives a request that a target programmable two-dimensional code for positioning the target location needs to be generated, a programmable two-dimensional code encoding request including a GPS identifier is generated, and the terminal is triggered to add the identifier to a piece of target code, where the target code is used for calling the GPS corresponding to the identifier to position the target location. The target code is then encoded to obtain a target programmable two-dimensional code. Subsequently, the target code may be obtained by scanning the target programmable two-dimensional code, and the target location may be positioned by running the target code.

In an optional solution, in this embodiment, the displaying the target programmable bar code includes at least one of the following: displaying, by the terminal, the target programmable bar code, and printing, by the terminal, the target programmable bar code on a target medium. It should be noted that the displaying the target programmable bar code may be to display the target programmable bar code on the terminal directly, or print the target programmable bar code on a target medium. The foregoing target medium includes but is not limited to the following: paper, cloth, plastic, glass, or the like.

Optionally, the foregoing embodiment may be further applied to cryptography. Previous cryptographic encryption results are all static characters. The encryption results may be dynamically changed at any time by using similar principles of programmable two-dimensional codes, and a permission of a reader may be authenticated, providing a new solution for information security.

Optionally, because the bar code has a limit on the length of text content, written target code is required to be optimized to be as concise as possible. For example, simple custom language rules for encoding target code may be, but are not limited to the following:.

For example, instance code may be as shown in <FIG>. A validity period is set for the code, and a time difference between a current time and <NUM>-<NUM>-<NUM> (only for the exemplary purpose) is calculated. If the time difference is within <NUM> minute, "valid" is prompted, and two-dimensional code information is obtained; and otherwise, "invalid" is prompted.

According to another aspect of the embodiments of this application, a method for scanning a bar code is further provided, and the method may be applied to the environment shown in <FIG>. The method for scanning a bar code as shown in <FIG> may include:.

It should be noted that the foregoing programmable bar code may be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). For example, personal information on a ticket is carried in target code, and then a bar code carrying the target code is printed on the ticket, so that content carried in the bar code may be the personal information on the ticket. The programmable bar code may be further applied to location positioning. For example, the target code carries information for calling corresponding positioning hardware, and then a bar code carrying the target code is printed on a ticket, so that the positioning hardware may be called by scanning the bar code to position, and content carried in the bar code may be the information for calling the corresponding positioning hardware. The foregoing description is only two examples and this embodiment does not impose any limitation on this.

A scanned programmable bar code is obtained by encoding target code, that is, information carried in the programmable bar code is the target code. Because the target code implements logical judgments and simple algorithms, the target code may be run to implement various logical functions, and greatly expand a range of information carried in a bar code, so that the programmable bar code is applicable to more complex scenarios and has more abundant applications. Therefore, this embodiment of this application resolves the problem in the related art that information carried in a bar code is relatively simple.

It should be noted that the scanning a target programmable bar code to obtain target code may be implemented by using, but not limited to the following method: inputting a scanned target programmable bar code into a decoding algorithm corresponding to an encoding algorithm, to decode the target programmable bar code, and if the target code is encrypted in an encoding process, performing corresponding decryption after decoding to obtain the target code.

For example, the foregoing target code is used for executing at least one of the following target logical functions:.

For example, in a case that the target code is used for executing the foregoing target logical function, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: obtaining an identifier of the target hardware in a target device; and calling the target hardware indicated by the identifier to execute the target operation.

For another example, the scanning a target programmable bar code to obtain target code may be implemented by using, but not limited to the following method: scanning, by the terminal on a target medium, a target programmable bar code carrying a parameter that identifies target hardware used for positioning a target location in the terminal, to obtain the target code. Optionally, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: obtaining, by the terminal, the identifier of the target hardware according to the parameter that identifies the target hardware used for positioning the target location in the terminal, and calling, by the terminal, the target hardware indicated by the identifier to position the target location, and then displaying the positioned target location.

In an optional solution, in this embodiment, the scanning the target programmable bar code to obtain target code may be implemented by using, but not limited to the following method: decoding a scanned target programmable bar code by using a decoding algorithm corresponding to the encoding algorithm, to obtain the target code. As compared with the related art, in this embodiment of this application, text information is not obtained after decoding directly, but corresponding target code is obtained, so that corresponding information of the target code cannot be obtained in a case that a piece of code obtained by decoding the bar code is not run, to avoid information leakage.

Description is specifically made with reference to the following example. As shown in <FIG>, it is assumed that the target code has been written, the foregoing target programmable two-dimensional code is decoded by using a two-dimensional code decoder on a terminal <NUM>, to obtain the corresponding target code. A target two-dimensional code decoding algorithm may be installed in the foregoing two-dimensional code decoder, and the target two-dimensional code decoding algorithm may be an existing target two-dimensional code decoding algorithm.

In an optional solution, in this embodiment, when the target code is used for executing the foregoing first target logical function, running the target code to execute the target logical function may be implemented by using, but not limited to the following method: running the target code, and determining whether the target account has a read permission, the target account being used for scanning the target programmable bar code. Displaying a result obtained by executing the target logical function may be implemented by using, but not limited to the following method: displaying the result obtained by executing the target logical function when it is determined that the target account has a read permission. Through the foregoing embodiment, a bar code read permission is limited, and security of a bar code is improved.

For example, the foregoing embodiment may be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). Description is made still by using a train ticket as an example. Description is specifically made with reference to the following example, as shown in <FIG>. When a tourist A's train ticket is checked, the ticket inspector uses the device in the hands to scan the two-dimensional code on the train ticket, to obtain the target code embedded in the two-dimensional code. Because the device in the hands of the ticket inspector has a permission to read the foregoing two-dimensional code, A's identification card information may be obtained by successfully running the target code, to determine whether it is A who takes the train.

In an optional solution, in this embodiment, in a case that the target code is used for executing the foregoing first target logical function, running the target code to execute the target logical function may be implemented by using, but not limited to the following method: running the target code, and determining whether a target programmable bar code is within the validity period. The result obtained by executing the target logical function may be displayed by using, but not limited to the following method: displaying the result obtained by executing the target logical function after it is determined that the target programmable bar code is within the validity period. Through the foregoing embodiment, the bar code is valid within a validity period, and bar code security is improved.

In an optional solution, in this embodiment, in a case that the target code is used for executing the foregoing first target logical function, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: obtaining an identifier of the target hardware in a target device; and calling the target hardware indicated by the identifier to execute the target operation. Through the foregoing embodiment, the target hardware may be called through the bar code, so that the bar code is applicable to more complex scenarios and has more abundant applications.

For example, the foregoing embodiment may be applied to location positioning. When the foregoing embodiment is applied to location positioning, description is made still by using an example in which the GPS in the terminal is called to position. The terminal scans the target programmable two-dimensional code, to obtain the target code including the GPS identifier. The terminal runs the target code, calls the GPS corresponding to the identifier to obtain the position information of the target location (that is, the current position), and then displays the information on the terminal.

In an optional solution, in this embodiment, the scanning a target programmable bar code to obtain target code may be implemented by using, but not limited to the following method: scanning, by the terminal, a target programmable bar code on a target medium to obtain the target code, the target programmable bar code carrying a parameter for identifying the target hardware used for positioning the target location in the terminal. Optionally, in this embodiment, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: obtaining, by the terminal, the identifier of the target hardware according to the foregoing parameter; and calling, by the terminal, the target hardware indicated by the identifier to position the target location. Optionally, in this embodiment, the result obtained by executing the target logical function may be displayed by using, but not limited to the following method: displaying, by the terminal, the target location.

In an optional solution, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: calling a predetermined virtual machine, the predetermined virtual machine being configured to run the target code; and running the target code on the predetermined virtual machine, to execute the target logical function. In this embodiment, the foregoing target code may be directly run on a virtual machine, or the virtual machine may be called through an application on the terminal, to run the target code on the virtual machine.

It should be noted that the foregoing target code may be a program that runs directly on a virtual machine, or may be code written through the integrated software development environment IDE to reduce carrying capacity of the two-dimensional code, but a tool for writing the code is not limited to the IDE.

It should be noted that when written through the integrated software development environment IDE, the target code needs to be converted into general front-end code (for example, js code) by a virtual machine in a decoding process.

To facilitate understanding of the foregoing embodiments, in this embodiment, description is made still by using an example in which the bar code is a two-dimensional code with reference to encoding and decoding of the programmable two-dimensional code.

As shown in <FIG>, in this embodiment of this application, the target code including original text (that is, the source code or the byte code shown in <FIG>) is written through the IDE first. The programmable two-dimensional code is then obtained by encoding the target code by using a two-dimensional code encoder. The target code is then obtained by decoding the programmable two-dimensional code by using a two-dimensional code decoder. At last, the original text is obtained by running the target code through the virtual machine. That is, an encoding and decoding process of a programmable two-dimensional code is as follows:.

During encoding, the code including the original text is written through the IDE to generate the source code or the byte code. Generated character strings are used as a parameter, and a two-dimensional code graphic is generated by using the existing two-dimensional code encoding algorithm.

During decoding and reading, information content is restored through image recognition and a decoding algorithm, that is, the source code or the byte code is retrieved by using the existing two-dimensional code decoding algorithm. The original text is obtained by executing/explaining code on a dedicated virtual machine.

Detailed description of encoding and decoding of a programmable two-dimensional code is made below by using an example in which a two-dimensional code validity period is set.

Content of the programmable two-dimensional code in this embodiment of this application is no longer static text information, but byte code generated by a programming language or the code itself. During scanning, the content obtained by using the existing two-dimensional code decoding technologies is not text itself but a piece of byte code or a piece of code. Information that a two-dimensional code expects to convey can be obtained only by running the piece of code. In this way, as compared with the previous two-dimensional code technologies, a read permission and an information validity period may be limited by writing code, and even hardware may be called, to complete other more complex logic. Therefore, the programmable two-dimensional code of this embodiment of this application greatly expands capability of a two-dimensional code, so that a static two-dimensional code has its own "consciousness", and the two-dimensional code is applicable to more complex scenarios and has more abundant applications. As compared with the existing two-dimensional code solutions, two-dimensional code graphics generated by the programmable two-dimensional code are more secure, more expandable, and have more prospects for use. Furthermore, the quantity of code bytes may be compressed by customizing a special two-dimensional code programming language to improve the execution efficiency of encoding and decoding.

Similar to ideas of dynamic two-dimensional codes, there will be similar applications in cryptography, and this helps improve current encryption security.

Optionally, in this embodiment, the foregoing terminal may include, but is not limited to, at least one of the following: a mobile phone, a tablet computer or the like.

It should be noted that for ease of description, the foregoing method embodiments are stated as a series of action combinations. However, a person skilled in the art needs to learn that this application is not limited to the described sequence of the actions because according to this application, some steps may use another sequence or may be simultaneously performed. In addition, it is to be understood by a person skilled in the art that the embodiments described in this specification are all preferred embodiments, and the actions and modules in the embodiments are not mandatory for this application.

Through the descriptions of the foregoing implementations, a person skilled in the art may clearly understand that the method according to the foregoing embodiments may be implemented by means of software and a necessary general hardware platform, and certainly, may also be implemented by hardware, but in many cases, the former manner is a better implementation. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the related art may be implemented in a form of a software product. The computer software product is stored in a storage medium (for example, a ROM/RAM, a magnetic disk, or an optical disc), and includes several instructions for instructing a terminal device (which may be a mobile phone, a computer, a server, a network device, or the like) to perform the methods according to the embodiments of this application.

According to another aspect of the embodiments of this application, an apparatus for displaying a bar code is further provided. As shown in <FIG>, the apparatus includes:.

It should be noted that the foregoing programmable bar code may be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). For example, personal information on a ticket is carried in target code, and then a bar code carrying the target code is printed on the ticket, so that content carried in the bar code may be the personal information on the ticket. The programmable bar code may also be applied to location positioning. For example, the target code carries information for calling corresponding positioning hardware, and then a bar code carrying the target code is printed on a ticket, so that the positioning hardware may be called by scanning the bar code to position, and content carried in the bar code may be the information for calling the corresponding positioning hardware. It should be noted that the foregoing description is only two examples and this embodiment does not impose any limitation on this.

In an optional implementation solution, a second obtaining unit <NUM> includes:.

Description is specifically made with reference to the following examples. As shown in <FIG>, it is assumed that the target code has been written, the character string of the target code is encoded by using a two-dimensional code encoder on the terminal <NUM> to obtain a corresponding target programmable two-dimensional code. A target two-dimensional code encoding algorithm may be installed in the foregoing two-dimensional code encoder, and the target two-dimensional code encoding algorithm may be an existing two-dimensional code encoding algorithm.

As compared with the related art, in this embodiment of this application, text information is no longer used as the input parameter of the two-dimensional code encoding algorithm, and instead, the character string of the target code is used as the input parameter of the two-dimensional code encoding algorithm. Therefore, the foregoing programmable two-dimensional code carries the target code, so that the two-dimensional code does not carry information but a piece of code, to avoid information leakage.

Optionally, the foregoing target code in this embodiment is used for executing at least one of the following target logical functions:.

Optionally, in this embodiment, the programmable bar code encoding request is obtained by using, but not limited to the following method: receiving, by a terminal, a target request that is used for requesting to generate a target programmable bar code corresponding to predetermined information (for example, the foregoing identification card information) of a target ticket, and generating, by the terminal in response to the request, a programmable bar code encoding request carrying the predetermined information. The generating a target programmable bar code in response to the programmable bar code encoding request may be implemented by using, but not limited to the following method: encoding, by the terminal, the target code to obtain the target programmable bar code, a parameter of the target code including the predetermined information.

Optionally, in this embodiment, the target code is further used for executing the following target logical function: a first target logical function, used for allowing an account having a read permission to run the target code, or allowing a device having a read permission to run the target code, or allowing a virtual machine having a read permission to run the target code. For example, the foregoing target code may include a permission to read a target programmable bar code, that is, only an account, a device, and the like having the foregoing permission can read the foregoing target programmable bar code, such as the two-dimensional code on the train ticket. Even if the target code is decoded, only a device that has a read permission and that is in the hands of a ticket inspector can run the target code to read the identification card information in the target programmable two-dimensional code, to determine whether the passenger is the right person.

Optionally, in this embodiment, the programmable bar code encoding request is obtained by using, but not limited to the following method: receiving, by a terminal, a target request that is used for requesting to generate a target programmable bar code corresponding to a target location, and generating, by the terminal in response to the request, a programmable bar code encoding request carrying an identifier that is used for positioning target hardware (for example, the foregoing GPS) of the target location. Optionally, in this embodiment, the generating a target programmable bar code in response to the programmable bar code encoding request includes: encoding, by the terminal, the target code to obtain the target programmable bar code, the target code including a parameter used for identifying the target hardware in the terminal, and the target logical function being used for calling the target hardware to position the target location.

Optionally, in this embodiment, the displaying the target programmable bar code includes at least one of the following: displaying, by the terminal, the target programmable bar code, and printing, by the terminal, the target programmable bar code on a target medium. The displaying the target programmable bar code may be to display the target programmable bar code on the terminal directly, or print the target programmable bar code on a target medium. The foregoing target medium includes but is not limited to the following: paper, cloth, plastic, glass, or the like.

According to another aspect of the embodiments of this application, a bar code scanning apparatus is further provided. As shown in <FIG>, the apparatus includes:.

The foregoing programmable bar code may be applied to a ticket (such as a train ticket, a movie ticket, or an attraction ticket). For example, personal information on a ticket is carried in target code, and then a bar code carrying the target code is printed on the ticket, so that content carried in the bar code may be the personal information on the ticket. The programmable bar code may be further applied to location positioning. For example, the target code carries information for calling corresponding positioning hardware, and then a bar code carrying the target code is printed on a ticket, so that the positioning hardware may be called by scanning the bar code to position, and content carried in the bar code may be the information for calling the corresponding positioning hardware. The foregoing description is only two examples and this embodiment does not impose any limitation on this.

In an optional solution, a scanning unit <NUM> includes:
a decoding module, configured to decode the scanned target programmable bar code by using a decoding algorithm corresponding to an encoding algorithm, to obtain the target code.

For example, the scanning a target programmable bar code to obtain target code may be implemented by using, but not limited to the following method: inputting a scanned target programmable bar code into a decoding algorithm corresponding to an encoding algorithm, and decoding the target programmable bar code to obtain the target code.

Optionally, in this embodiment, the scanning unit <NUM> is further used in, but not limited to the following method: scanning, by the terminal, a target programmable bar code on a target medium to obtain the target code, the target programmable bar code carrying a parameter for identifying the target hardware used for positioning the target location in the terminal.

Optionally, in this embodiment, a running unit <NUM> is further configured to, but is not limited to the following method: obtaining, by the terminal, the identifier of the target hardware according to the foregoing parameter; and calling, by the terminal, target hardware indicated by the identifier to position the target location.

Optionally, in this embodiment, a display unit <NUM> is further used in, but not limited to the following method: displaying, by the terminal, the target location.

It should be noted that in this embodiment, the foregoing target code may be directly run on a virtual machine, or the virtual machine may be called through an application on the terminal, to run the target code on the virtual machine. Optionally, the running the target code to execute the target logical function may be implemented by using, but not limited to the following method: calling a predetermined virtual machine, the predetermined virtual machine being configured to run the target code; and running the target code on the predetermined virtual machine to execute the target logical function.

According to still another aspect of the embodiments of this application, a storage medium is further provided. The storage medium stores a computer program, the computer program being configured to perform, during running, the steps in any one of the foregoing method embodiments.

Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or some of the steps of the methods in the foregoing embodiments may be implemented by a program by instructing hardware relevant to a terminal device. The program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disc, or the like.

According to still another aspect of the embodiments of this application, an electronic device configured to implement the foregoing programmable bar code display and scanning methods is further provided. As shown in <FIG>, the electronic device includes a processor <NUM> and a memory <NUM>. Optionally, the foregoing electronic device may further include: a display <NUM>, a user interface <NUM>, a transmission apparatus <NUM>, a sensor <NUM>, and the like. The memory stores a computer program. The processor is configured to perform the steps in any one of the foregoing method embodiments through the computer program.

Optionally, a person of ordinary skill in the art may understand that, the structure shown in <FIG> is only illustrative. The electronic device may alternatively be a terminal device such as a smartphone (for example, an Android mobile phone or an iOS mobile phone), a tablet computer, a palmtop computer, a mobile Internet device (MID), or a PAD. <FIG> does not constitute a limitation on the structure of the foregoing electronic device. For example, the electronic device may further include more or fewer components (for example, a network interface, or the like) than those shown in <FIG>, or have configuration different from that shown in <FIG>.

The memory <NUM> may be configured to store a software program and a module, for example, a program instruction/module corresponding to the bar code display and scanning method and the bar code display and scanning apparatus in the embodiments of this application, and the processor <NUM> executes various functional applications and data processing, that is, implements the bar code display and scanning method by running the software program and the module stored in the memory <NUM>. The memory <NUM> may include a high-speed random memory, and a non-volatile memory such as one or more magnetic storage devices, a flash, or another non-volatile solid-state memory. In some embodiments, the memory <NUM> may further include memories remotely disposed relative to the processor <NUM>, and these remote memories may be connected to a terminal through a network. An example of the foregoing network includes, but is not limited to, the Internet, an intranet, a local area network, a mobile communications network, or a combination thereof.

The foregoing transmission apparatus <NUM> is configured to receive or send data through a network. Specific examples of the foregoing network may include a wired network and a wireless network. In an example, the transmission apparatus <NUM> includes a network interface adapter (NIC) that may be connected to other network devices and routers through a network cable to communicate with the Internet or a local area network. In an example, the transmission apparatus <NUM> is a radio frequency (RF) module, which is configured to communicate with the Internet in a wireless manner.

The foregoing sensor <NUM> is configured to collect real environment data at a current real position of the terminal, the real environment data including meteorological data. The foregoing display <NUM> displays a programmable two-dimensional code. The user interface <NUM> is configured to obtain an input operation instruction, such as a programmable two-dimensional code encoding request, a target request, or the like.

The sequence numbers of the foregoing embodiments of this application are merely for description purpose, and do not indicate the preference among the embodiments.

In a case that the integrated unit in the foregoing embodiments is implemented in the form of a software functional unit and sold or used as an independent product, the integrated unit may be stored in the foregoing computer-readable storage medium. Based on such understanding, the technical solutions in this application essentially, or the part contributing to the related technology, or all or some of the technical solutions may be implemented in a form of a software product. The computer software product is stored in a storage medium and includes several instructions for instructing one or more computer devices (which may be a personal computer, a server, a network device, or the like) to perform all or some of steps of the methods in the embodiments of this application.

In the foregoing embodiments of this application, the descriptions of the embodiments have their respective focuses. For a part that is not described in detail in an embodiment, reference may be made to related descriptions in other embodiments.

In the several embodiments provided in this application, it is to be understood that the disclosed client may be implemented in other manners. The described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be another division in an actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, or direct coupling, or communication connection between the displayed or discussed components may be the indirect coupling or communication connection by means of some interfaces, units, or modules, and may be in electrical or other forms.

The units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. A part of or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.

Claim 1:
A method for bar code generation and display, applied to a terminal, comprising:
obtaining (S202) a bar code encoding request;
generating (S204) a target bar code embedded with a target code by encoding the target code in response to the bar code encoding request, the target code comprising a target logical function; the target code comprises a code character string compiled into a byte code or a customized proprietary programming language, and
displaying (S206) the target bar code.