Text encoding and decoding method, device, equipment and medium

By using preset mapping tables and mapping table reference sequences for text encoding, the problem of text encoding relying on word segmentation methods in the prior art is solved, efficient and accurate text encoding is achieved, and security is improved.

CN114936539BActive Publication Date: 2025-04-25BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210751727.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2025-04-25
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

The existing text encoding methods rely too much on word segmentation methods, resulting in different adaptive languages ​​and terminal devices, and the encoding text is distorted.

Method used

By obtaining the text to be encoded and multiple preset mapping tables, the target encoding identifier is determined from the preset mapping table based on the mapping table reference sequence, and text encoding in characters is realized.

Benefits of technology

It saves the process of word segmentation and word list construction, avoids the problem of text encoding relying on word segmentation methods and text distortion, improves text encoding efficiency and accuracy, increases cracking difficulty and improves security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114936539B_ABST
    Figure CN114936539B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text encoding and decoding method, device, equipment and medium. The text encoding method includes: obtaining a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record the one-to-one correspondence between the characters constituting the text and the first encoding identifier, and the preset mapping table is used to record the one-to-one correspondence between the information in the reference mapping table and the second encoding identifier; based on the first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, the first target mapping table corresponding to the target character is determined from each preset mapping table, and the first target mapping table is queried based on the target character to determine the target encoding identifier corresponding to the target character; based on the target encoding identifier corresponding to each target character in the text to be encoded, a target encoded text is generated. According to the embodiment of the present disclosure, the accuracy and security of text encoding are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a text encoding and decoding method, device, equipment and medium. Background Art

[0002] Text digitization or text encoding is a basic text encryption method in the field of data security.

[0003] In the prior art, text encoding is mainly achieved through the "segmentation + vocabulary" method. In the encoding stage, this method first segmented a text to obtain multiple words separated by spaces, and then converted each word into a corresponding coding identifier (such as a number or character, etc.) according to a pre-established vocabulary. The words not recorded in the vocabulary are uniformly converted into the coding identifier of "unknown word (UNK)", and the encoded text can be obtained. In the decoding stage, the coding identifiers in the encoded text will be converted into corresponding words according to the above vocabulary, and the obtained vocabulary sequences will be spliced ​​together according to grammatical rules to obtain the decoded text.

[0004] However, the above method has at least the following problems: On the one hand, because different word segmentation methods require different word lists, the adapted languages ​​may be different, and the adapted terminal devices may be different, the above text encoding method is too dependent on the word segmentation method. On the other hand, because spaces are inserted between words after word segmentation, the original space information in the text is lost, or the words that are not in the word list are uniformly converted into the encoding mark of "unknown word (UNK)", etc., all of which will cause the encoded text to be distorted. Summary of the invention

[0005] In order to solve the technical problems that the above-mentioned text encoding process is too dependent on the word segmentation method and the encoded text is distorted, the present disclosure provides a text encoding and decoding method, device, equipment and medium.

[0006] In a first aspect, the present disclosure provides a text encoding method, the method comprising:

[0007] Obtaining a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first encoding identifier, and the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and a second encoding identifier;

[0008] Based on a first arrangement position of a target character in the text to be encoded in the text to be encoded and a mapping table reference sequence, determining a first target mapping table corresponding to the target character from each of the preset mapping tables, and querying the first target mapping table based on the target character to determine a target encoding identifier corresponding to the target character;

[0009] A target encoded text is generated based on the target encoding identifier corresponding to each target character in the text to be encoded.

[0010] In a second aspect, the present disclosure further provides a text decoding method, the method comprising:

[0011] Obtaining a text to be decoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first encoding identifier, and the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and a second encoding identifier;

[0012] Based on the third arrangement position of the target code identifier in the text to be decoded in the text to be decoded and the mapping table reference sequence, determine the second target mapping table corresponding to the target code identifier from each of the preset mapping tables, and query the second target mapping table based on the target code identifier to determine the decoding character corresponding to the target code identifier;

[0013] A target decoded text is generated based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

[0014] In a third aspect, the present disclosure further provides a text encoding device, the device comprising:

[0015] A first information acquisition module, used to acquire a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first encoding identifier, and the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and a second encoding identifier;

[0016] a target encoding identifier determining module, configured to determine a first target mapping table corresponding to the target character in the text to be encoded from each of the preset mapping tables based on a first arrangement position of the target character in the text to be encoded and a mapping table reference sequence, and to query the first target mapping table based on the target character to determine a target encoding identifier corresponding to the target character;

[0017] The target coded text generation module is used to generate the target coded text based on the target coding identifier corresponding to each target character in the text to be encoded.

[0018] In a fourth aspect, the present disclosure further provides a text decoding device, the device comprising:

[0019] A second information acquisition module, used to acquire a text to be decoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first encoding identifier, and the preset mapping table is used to record a one-to-one correspondence between the information in the reference mapping table and a second encoding identifier;

[0020] A decoding character determination module is used to determine a second target mapping table corresponding to the target coding identifier in the text to be decoded from each of the preset mapping tables based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, and query the second target mapping table based on the target coding identifier to determine a decoding character corresponding to the target coding identifier;

[0021] The target decoded text generation module is used to generate a target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

[0022] In a fifth aspect, the present disclosure provides an electronic device, the electronic device comprising:

[0023] processor;

[0024] A memory for storing executable instructions;

[0025] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the text encoding method or text decoding method described in any embodiment of the present disclosure.

[0026] In a sixth aspect, the present disclosure provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor implements the text encoding method or text decoding method described in any embodiment of the present disclosure.

[0027] The text encoding and decoding method, apparatus, device and medium provided by the embodiments of the present disclosure can obtain multiple preset mapping tables for recording the one-to-one mapping relationship between characters constituting the text and the encoding identifiers according to the reference mapping tables in the relevant technology, and select the preset mapping table adapted to the characters to be encoded (characters to be decoded) in the text to be encoded (text to be decoded) from multiple preset mapping tables according to the mapping table reference sequence, and map the corresponding characters to be encoded (characters to be decoded) to the corresponding target encoding identifiers (decoded characters) to obtain the target encoded text (decoded text); realize text encoding and decoding in units of characters, save the process of word segmentation and building a word table adapted to the word segmentation method, avoid the problem of text encoding dependence on the word segmentation method and text distortion, and improve text encoding efficiency and text encoding accuracy; in addition, the preset mapping table used for each character is determined by the mapping table reference sequence, which increases the difficulty of cracking the text encoding to a certain extent, thereby improving the security of the text encoding. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0029] Figure 1 A flowchart of a text encoding method provided by an embodiment of the present disclosure;

[0030] Figure 2 A flowchart of a text decoding method provided by an embodiment of the present disclosure;

[0031] Figure 3 A structural schematic diagram of a text encoding device provided by an embodiment of the present disclosure;

[0032] Figure 4 A structural diagram of a text decoding device provided by an embodiment of the present disclosure;

[0033] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0034] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0035] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0036] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0037] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0038] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0039] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0040] Figure 1 A flowchart of a text encoding method provided by an embodiment of the present disclosure is shown.

[0041] The text encoding method provided by the embodiment of the present disclosure can be applied to scenarios such as digital conversion of text, text encryption, and text compression. The method can be performed by a text encoding device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device with certain computing capabilities. The electronic device can include but is not limited to mobile terminals such as smart phones, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), notebook computers, PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, servers, etc.

[0042] like Figure 1 As shown, the text encoding method may include the following steps:

[0043] S110, obtain the text to be encoded and multiple preset mapping tables; the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record the one-to-one correspondence between the characters constituting the text and the first encoding identifier, and the preset mapping table is used to record the one-to-one correspondence between the information in the reference mapping table and the second encoding identifier.

[0044] The text to be encoded is the text that needs to be encoded, which can be a sentence, a paragraph or a whole article. The preset mapping table is a pre-set record table for recording the characters constituting the text and their corresponding encoding identifiers. The characters here can be words and symbols in any language, such as English letters, Chinese characters, punctuation marks, special symbols, etc.

[0045] In the disclosed embodiment, the preset mapping table is generated based on the reference mapping table, and is used to record the one-to-one correspondence between the information in the reference mapping table and the second encoding identifier. That is, the preset mapping table is obtained by processing the information contained in the reference mapping table, and the second encoding identifier is the encoding identifier obtained by the processing. The reference mapping table is a record table for character encoding in the relevant technology, such as the American Standard Code for Information Interchange (ASCII) comparison table, the Chinese character encoding character set GBK encoding table, the Unicode character list, the UTF-8 encoding table, etc., which is used to record the one-to-one correspondence between the characters constituting the text and the first encoding identifier. The first encoding identifier is the encoding identifier in the reference mapping table.

[0046] In one example, the reference mapping table is a Unicode character list. Then, the first encoding identifier is the number corresponding to the character. This ensures that all characters in various languages ​​can correspond to encoding identifiers, avoiding the situation where the encoding identifiers of some characters cannot be determined.

[0047] Specifically, the electronic device can obtain the text to be encoded corresponding to the instruction according to the text processing related instruction, such as text transmission instruction, text encryption instruction, text compression instruction, etc. In addition, the electronic device reads multiple preset mapping tables from the local storage space or external storage medium, or the electronic device pulls multiple preset mapping tables from the network end to encode the text to be encoded.

[0048] In some embodiments, obtaining the preset mapping table in S110 includes: randomly sorting or performing random number operations on each first coding identifier contained in the reference mapping table to obtain each second coding identifier; generating the preset mapping table based on the information contained in the reference mapping table and each second coding identifier.

[0049] The information contained in the reference mapping table includes each character and / or each first encoding identifier in the reference mapping table.

[0050] Specifically, the processing method for the electronic device to generate each preset mapping table based on the reference mapping table may be to perform a certain degree of transformation processing on each first coding identifier contained in the reference mapping table to obtain a set of new coding identifiers. For example, the electronic device performs random sorting processing on each first coding identifier, such as calling the random.shuffle() function on each first coding identifier, to obtain a set of reordered first coding identifiers as each second coding identifier. For another example, the electronic device may perform random number calculation on each coding identifier in each first coding identifier to obtain a corresponding new coding identifier, and may also obtain each second coding identifier. Then, the electronic device may form a preset mapping table with each character and each second coding identifier contained in the reference mapping table. Alternatively, the electronic device may form a preset mapping table with each first coding identifier and each second coding identifier contained in the reference mapping table.

[0051] In some embodiments, the number of preset mapping tables is greater than or equal to the cardinality of the counting system of the mapping table reference sequence. The mapping table reference sequence in the embodiment of the present disclosure is a digital sequence used to identify the order of use of each preset mapping table. The numbers in the digital sequence at least cover the mapping table identifiers of each preset mapping table, and the mapping table identifiers are represented in a certain counting system. Therefore, the number of preset mapping tables must be greater than or equal to the cardinality of the counting system of the mapping table reference sequence to avoid the situation where the numbers in the mapping table reference sequence cannot correspond to a specific preset mapping table, thereby further improving the accuracy of text encoding. For example, if the counting system of the mapping table reference sequence is hexadecimal, then its cardinality is 16, and accordingly, the number of preset mapping tables is at least 16.

[0052] S120. Based on the first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, determine the first target mapping table corresponding to the target character from each preset mapping table, and query the first target mapping table based on the target character to determine the target encoding identifier corresponding to the target character.

[0053] The target character is a character contained in the text to be encoded and needs to be converted. The first arrangement position is the character arrangement position of the target character in the text to be encoded. For example, if the character arrangement position of the target character in the text to be encoded is the 9th character, then the first arrangement position is 9. The first target mapping table is a preset mapping table selected from various preset mapping tables during the encoding process. The target encoding identifier is the encoding identifier of the target character determined from the preset mapping table.

[0054] Specifically, in order to improve the security of the text, multiple preset mapping tables are used in the embodiment of the present disclosure, and these preset mapping tables are not directly arranged in sequence according to the mapping table identifiers. Therefore, after the electronic device obtains the text to be encoded and multiple preset mapping tables, it can obtain the mapping table reference sequence. The mapping table reference sequence can be a fixed digital sequence predetermined after determining the identifiers of each mapping table, or it can be a temporary digital sequence obtained by regularly changing the above fixed digital sequence according to certain rules, or it can be a text customized digital sequence generated according to relevant information in the text to be encoded.

[0055] In specific implementation, the electronic device may perform the same encoding process on the target characters in the text to be encoded. The target characters here may be determined according to a predetermined encoding rule. For example, the target characters may be characters with a certain character spacing in the text to be encoded; the target characters may also be every character in the text to be encoded.

[0056] The above encoding process may be: first determine the first arrangement position of the target character in the text to be encoded. Then, query the mapping table reference sequence with the first arrangement position to obtain the corresponding mapping table identifier (i.e., the first mapping table identifier) ​​in the mapping table reference sequence. After that, locate the first target mapping table according to the first mapping table identifier. Finally, query the first target mapping table according to the target character to obtain the target encoding identifier.

[0057] It should be noted that if the first target mapping table records a one-to-one correspondence between a character and a second coding identifier, the electronic device can directly query the first target mapping table according to the target character to obtain the target coding identifier. If the first target mapping table records a one-to-one correspondence between a first coding identifier and a second coding identifier, the electronic device needs to first query the reference mapping table according to the target character to determine its corresponding first coding identifier, and then query the first target mapping table according to the determined first coding identifier to obtain its corresponding target coding identifier.

[0058] In some embodiments, in S120, based on the first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, determining the first target mapping table corresponding to the target character from each preset mapping table includes: determining the second arrangement position based on the first arrangement position and the sequence length of the mapping table reference sequence; determining the first mapping table identifier at the second arrangement position from the mapping table reference sequence, and determining the preset mapping table corresponding to the first mapping table identifier as the first target mapping table.

[0059] The process of determining the first target mapping table can be specifically implemented as follows: the electronic device determines the first arrangement position offset of the target character in the text to be encoded. Then, the electronic device can perform a modulo calculation on the first arrangement position and the sequence length of the mapping table reference sequence, and use the obtained result as the second arrangement position, so that when the text length of the text to be encoded is greater than the sequence length of the mapping table reference sequence, the mapping table reference sequence is cyclically used.

[0060] For example, the mapping table references a hexadecimal digital string sequence "3617b3d66d38049664288366ce2ef9f8b9747883" with a sequence length of 40, and the first arrangement position determined by the electronic device is 43. Then, a modulo operation can be performed on the first arrangement position and the sequence length, that is, 43%40, to obtain a remainder 3, and the second arrangement position can be obtained as 3.

[0061] Then, the electronic device searches for the numeric character at the second arrangement position 3 from the mapping table reference sequence to obtain the first mapping table identifier "1". After that, the electronic device selects the preset mapping table with the mapping table identifier "1" from each preset mapping table according to the first mapping table identifier "1" as the first target mapping table.

[0062] S130, generating a target coded text based on the target coding identifier corresponding to each target character in the text to be coded.

[0063] Specifically, according to the process of S120, the electronic device can obtain the target coding identifier corresponding to each target character contained in the text to be coded. Then, the electronic device can generate the target coded text according to the arrangement relationship of each target character in the text to be coded by each target coding identifier. After that, the electronic device can perform the processing flow corresponding to the instruction on the target coded text according to the relevant instruction of text processing.

[0064] The above-mentioned text encoding method provided by the embodiment of the present disclosure can obtain multiple preset mapping tables for recording the one-to-one mapping relationship between the characters constituting the text and the encoding identifiers according to the reference mapping table in the relevant technology, and select the preset mapping table adapted to the characters to be encoded in the to-be-encoded text from the multiple preset mapping tables according to the mapping table reference sequence, and map the corresponding characters to be encoded to the corresponding target encoding identifiers to obtain the target encoded text; it realizes text encoding and decoding in units of characters, saves the process of word segmentation and building a vocabulary table adapted to the word segmentation method, avoids the problem of text encoding dependence on the word segmentation method and text distortion, and improves text encoding efficiency and text encoding accuracy; in addition, the preset mapping table adopted by each character is determined by the mapping table reference sequence, which increases the difficulty of cracking the text encoding to a certain extent, thereby improving the security of the text encoding.

[0065] In some embodiments, before S120, the text encoding method further includes: determining a mapping table reference sequence based on the text to be encoded.

[0066] Specifically, in this embodiment, the electronic device can generate a mapping table reference sequence based on the relevant information of the text to be encoded. For example, a hash operation is performed on the text to be encoded or its attribute information, and the hash operation result is used as the mapping table reference sequence. In this way, a mapping table reference sequence customized for the text can be obtained, ensuring that the same text has the same mapping table reference sequence, while different texts have different mapping table reference sequences, thereby ensuring the encoding consistency of the text and ensuring that the encoding results of similar texts cannot be cracked by differential analysis, thereby further increasing the difficulty of text encoding cracking and further improving the security of the text.

[0067] In some other embodiments, before S120, the text encoding method further includes: determining a mapping table reference sequence based on the text to be encoded and the encoding check value.

[0068] Among them, the coding check value is the check value used in the coding stage, which is at least used to verify the legitimacy of the text data. In the disclosed embodiment, the coding check value is also used to generate a mapping table reference sequence to further increase the confidentiality of the mapping table reference sequence, thereby further improving the security of the text. In one example, the coding check value can be a pre-set default value. In another example, the coding check value can be a user ID. This ensures that the coded texts of the same text of different users are different, thereby isolating user data and further improving the confidentiality and security of user text data.

[0069] Specifically, in this embodiment, the electronic device can use the relevant information of the text to be encoded and the encoding check value to generate a mapping table reference sequence. For example, the electronic device can combine the text to be encoded and the encoding check value first and then perform a hash operation, or perform a hash operation separately and then combine, or perform a multi-layer hash operation, etc., and use the final result as the mapping table reference sequence.

[0070] In one example, the electronic device may perform a hash operation on the text to be encoded, or a combination of the text to be encoded and the encoding verification value, to generate a first text hash value; and generate a mapping table reference sequence based on the first text hash value and the encoding verification.

[0071] The first text hash value is a hash value corresponding to the text to be encoded.

[0072] Specifically, the electronic device may first perform a hash operation on the text to be encoded to generate the result of the first hash operation, i.e., the first text hash value. Alternatively, the electronic device may first combine the text to be encoded and the encoding check value, such as splicing the encoding check value after the text to be encoded, and perform a hash operation on the combined result to obtain the first text hash value. Then, the electronic device combines the first text hash value and the encoding check value, and performs a second hash operation on the combined result, and the resulting hash value may be used as a mapping table reference sequence.

[0073] In another example, the electronic device may only perform a hash operation on the combination of the to-be-encoded text and the encoding check value to obtain a first text hash value, and use the first text hash value as a mapping table reference sequence.

[0074] In another example, the electronic device may perform a hash operation on the text to be encoded or its attribute information to obtain a first text hash value, and perform a hash operation on the encoded check value, and then perform various post-processing such as addition and subtraction on the results of the two hash operations, and use the results obtained from the post-processing as a mapping table reference sequence.

[0075] In some embodiments, based on the above-mentioned embodiment of generating a mapping table reference sequence by a first text hash value and a coding check, S130 includes: generating a target coded text based on a target coding identifier corresponding to each target character in the text to be encoded and the first text hash value.

[0076] Specifically, in the case where a mapping table reference sequence is generated by a first text hash value and a coding check, the mapping table reference sequence may not be shared, but the above-mentioned first text hash value may be carried in the target encoded text to further increase the confidentiality of the mapping table reference sequence, thereby further increasing the difficulty of text cracking and further improving the security of the text.

[0077] For example, the electronic device first generates an initial coded text corresponding to the text to be coded from each target coding identifier. Then, the electronic device concatenates the first text hash value with the initial coded text to obtain the target coded text. In this way, after the decoder obtains the target coded text, it can obtain the first text hash value through the target coded text, and then generate a mapping table reference sequence according to the first text hash value in the above-mentioned manner of generating a mapping table reference sequence.

[0078] In other embodiments, based on the above-mentioned embodiment of generating a mapping table reference sequence by the first text hash value and the encoding verification, S130 includes: generating a target encoded text based on the target encoding identifier corresponding to each target character in the text to be encoded, the first verification hash value and the first text hash value.

[0079] The first verification hash value is a hash value of the encoded verification value, that is, a hash value obtained by performing a hash operation on the encoded verification value.

[0080] Specifically, according to the above description, when the electronic device generates the target coded text, it can further concatenate the first verification hash value with the initial coded text. In this way, the decoder can obtain the first verification hash value on the basis of generating the mapping table reference sequence by itself, and verify the legitimacy of the target coded text according to the decoding verification value stored in the decoder and corresponding to the encoding verification value, which can not only prevent the target coded text containing offensive information from attacking the decoder, and provide security protection for the decoder, but also prevent the decoder from obtaining text data that does not belong to it, and provide security protection for the text data.

[0081] For example, the text to be encoded is "char1 char2 char3 char4", and after the processing of the above embodiments, the target encoded text "code1 code2 code3 code4 owner_id_hashtext_hash" can be obtained. Here, owner_id_hash is the first verification hash value, and text_hash is the first text hash value.

[0082] Figure 2 A flowchart of a text decoding method provided by an embodiment of the present disclosure is shown.

[0083] The text decoding method provided by the embodiment of the present disclosure can be applied to scenarios such as digital conversion of text, text encryption, and text compression. The method can be performed by a text decoding device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device with certain computing capabilities. The electronic device can include but is not limited to mobile terminals such as smart phones, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), notebook computers, PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, servers, etc.

[0084] like Figure 2 As shown, the text decoding method may include the following steps:

[0085] S210, obtaining the text to be decoded and multiple preset mapping tables; the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record the one-to-one correspondence between the characters constituting the text and the first encoding identifier, and the preset mapping table is used to record the one-to-one correspondence between the information in the reference mapping table and the second encoding identifier.

[0086] The text to be decoded is the text that needs to be converted into readable characters. In the disclosed embodiment, the text to be decoded is the encoded text generated by the text encoding process of the above embodiments.

[0087] Specifically, in the text decoding stage, the electronic device needs to obtain the same multiple preset mapping tables as in the text encoding stage, and the electronic device will respond to the relevant instructions of text processing to obtain the text to be decoded.

[0088] S220. Based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, determine the second target mapping table corresponding to the target coding identifier from each preset mapping table, and query the second target mapping table based on the target coding identifier to determine the decoding character corresponding to the target coding identifier.

[0089] The target coding identifier is a coding identifier contained in the text to be decoded and needs to be decoded. The third arrangement position is the arrangement position of the target coding identifier in the text to be decoded. The second target mapping table is a preset mapping table selected from various preset mapping tables during the decoding process. The decoded character is the character in the text obtained after text decoding.

[0090] Specifically, according to the description of each embodiment of the above text encoding, in the decoding stage, the electronic device will obtain the same mapping table reference sequence. In the case where the mapping table reference sequence is generated by the first text hash value and the encoding check, the electronic device will refer to the above process of generating the mapping table reference sequence to generate the mapping table reference sequence by itself for text decoding; in other cases, the electronic device can perform text decoding through the shared mapping table reference sequence.

[0091] In specific implementation, the electronic device can perform the same decoding process on the target coding identifier in the text to be decoded. The target coding identifier here can also be determined according to a predetermined coding rule, and the determination process of the target coding identifier is consistent with the determination process of the target character. For example, when the target character is a character with a certain character spacing in the text to be encoded, the target coding identifier is a coding identifier with the same character spacing in the text to be decoded; when the target character is each character in the text to be encoded, the target coding identifier is each coding identifier in the text to be decoded.

[0092] The above decoding process may be: first determine the third arrangement position of the target encoding identifier in the text to be decoded. Then, query the mapping table reference sequence with the third arrangement position to obtain the corresponding mapping table identifier (i.e., the second mapping table identifier) ​​in the mapping table reference sequence. After that, locate the second target mapping table according to the second mapping table identifier. Finally, query the second target mapping table according to the target encoding identifier to obtain the corresponding decoding character.

[0093] It should be noted that if the second target mapping table records a one-to-one correspondence between a character and a second coding identifier, the electronic device can directly query the second target mapping table according to the target coding identifier to obtain a decoded character. If the second target mapping table records a one-to-one correspondence between a first coding identifier and a second coding identifier, the electronic device needs to first query the second target mapping table according to the target coding identifier to determine the first coding identifier corresponding to the target coding identifier, and then query the reference mapping table according to the determined first coding identifier to obtain its corresponding decoded character.

[0094] In some embodiments, in S220, based on the third arrangement position of the target encoding identifier in the text to be decoded and the mapping table reference sequence, determining the second target mapping table corresponding to the target encoding identifier from each preset mapping table includes: determining the fourth arrangement position based on the third arrangement position and the sequence length of the mapping table reference sequence; determining the second mapping table identifier at the fourth arrangement position from the mapping table reference sequence, and determining the preset mapping table corresponding to the second mapping table identifier as the second target mapping table.

[0095] Specifically, the process of determining the second target mapping table can be specifically implemented as follows: the electronic device determines the third arrangement position offset of the target encoding identifier in the text to be decoded. Then, the electronic device can perform a modulo calculation on the third arrangement position and the sequence length of the mapping table reference sequence, and use the obtained result as the fourth arrangement position, so that when the text length of the text to be decoded is greater than the sequence length of the mapping table reference sequence, the mapping table reference sequence is cyclically used.

[0096] For example, the mapping table references a hexadecimal digital string sequence "3617b3d66d38049664288366ce2ef9f8b9747883" with a sequence length of 40, and the third arrangement position determined by the electronic device is 51. Then, a modulo operation can be performed on the third arrangement position and the sequence length, that is, 51%40, to obtain a remainder of 11, and the fourth arrangement position can be obtained as 11.

[0097] Then, the electronic device searches for the numeric character at the fourth arrangement position 11 from the mapping table reference sequence to obtain the second mapping table identifier "3". After that, the electronic device selects the preset mapping table with the mapping table identifier "3" from each preset mapping table according to the second mapping table identifier "3" as the second target mapping table.

[0098] S230: Generate a target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

[0099] Specifically, according to the process of S220, the electronic device can obtain the decoding characters corresponding to each target coding identifier contained in the text to be decoded. Then, the electronic device can generate the target decoded text from each decoding character according to the arrangement relationship of each target coding identifier in the text to be encoded.

[0100] The above-mentioned text decoding method provided by the embodiment of the present disclosure can obtain multiple preset mapping tables for recording the one-to-one mapping relationship between the characters constituting the text and the encoding identifiers according to the reference mapping table in the relevant technology, and select the preset mapping table adapted to the characters to be decoded in the text to be decoded from the multiple preset mapping tables according to the mapping table reference sequence, and map the corresponding characters to be decoded to the corresponding decoding characters to obtain the decoded text; it realizes text encoding and decoding in units of characters, saves the process of word segmentation and building a word table adapted to the word segmentation method, avoids the problem of text encoding dependence on the word segmentation method and text distortion, and improves text encoding efficiency and text encoding accuracy; in addition, the preset mapping table used for each character is determined by the mapping table reference sequence, which increases the difficulty of cracking the text encoding to a certain extent, thereby improving the security of the text encoding.

[0101] In some embodiments, the text to be decoded also includes a first verification hash value and / or a first text hash value.

[0102] The first verification hash value is a hash value of the encoding verification value. The encoding verification value is a verification value in the decoding stage, which is consistent with the encoding verification value, for example, it can be a user identifier. The first text hash value is a hash value of the text to be encoded, or a hash value of a combination of the text to be encoded and the encoding verification value.

[0103] Specifically, according to the description of the above embodiments, the text to be decoded may carry a first verification hash value and / or a first text hash value.

[0104] In some embodiments, when the text to be decoded includes a first verification hash value, after S210, the text decoding method also includes: performing a hash operation on the decoding verification value to generate a second verification hash value; when it is determined that the second verification hash value is equal to the first verification hash value, it is determined that the decoding verification is successful, and triggering execution of S220.

[0105] Specifically, when the text to be decoded contains a first verification hash value, the electronic device can verify the legitimacy of the text to be decoded according to the decoding verification value.

[0106] The electronic device first uses the hash algorithm for obtaining the first verification hash value to perform a hash operation on the decoding verification value to obtain a second verification hash value. Then, the electronic device compares the first verification hash value and the second verification hash value. If the comparison result is that the two are inconsistent, it means that the encoding verification value and the decoding verification value are inconsistent, which further indicates that the text to be decoded does not belong to the text that the decoder needs to decode, and the text decoding process is terminated. If the comparison result is that the two are consistent, it means that the encoding verification value and the decoding verification value are consistent, which further indicates that the text to be decoded belongs to the legitimate data of the decoder, that is, the decoding verification is successful. At this time, the subsequent process can be triggered, that is, the execution of S220 can be triggered. In this way, it can prevent the text to be decoded containing offensive information from attacking the decoder and realize the security protection of the decoder. It can also prevent the decoder from obtaining text data that does not belong to it and perform security protection on the text data.

[0107] In some embodiments, when the text to be decoded includes a first text hash value, before S220, the text decoding method further includes: generating a mapping table reference sequence based on the first text hash value and the decoding check value.

[0108] Specifically, if there is no shared mapping table reference sequence, and the text to be decoded carries the first text hash value, then during the decoding process, the electronic device can generate the mapping table reference sequence using the first text hash value and the decoding check value according to the same process of generating the mapping table reference sequence in each embodiment of the above text encoding. This can further ensure the confidentiality of the mapping table reference sequence, further increase the difficulty of decoding, and thus further improve the security of the text.

[0109] For example, the electronic device uses the same hash algorithm to perform a hash operation on a combination of the first text hash value and the decoding check value to generate a mapping table reference sequence.

[0110] In some embodiments, when the text to be decoded includes a first text hash value, after S230, the text decoding method further includes: performing a hash operation on the target decoded text, or a combination of the target decoded text and a decoding check value, to generate a second text hash value; and when it is determined that the second text hash value is equal to the first text hash value, determining that the text decoding is successful.

[0111] Specifically, referring to the generation process of the first text hash value mentioned above, the electronic device can use the same hash algorithm to perform a hash operation on the target decoded text to generate a second text hash value; or, the electronic device can use the same hash algorithm to perform a hash operation on the combination of the target decoded text and the decoding check value to obtain a second text hash value. Then, the electronic device compares the first text hash value and the second text hash value. If the comparison result is that the two are inconsistent, it means that there is an error in the decoding process. In the case of successful decoding verification, it may be that the second target mapping table determined according to the mapping table reference sequence is wrong, which can be checked and re-decoded. If the comparison result is that the two are consistent, it means that the decoding is correct, that is, the target decoded text is consistent with the text to be encoded.

[0112] It should be noted that the generation process of the second text hash value is consistent with the generation process of the first text hash value. That is, when the first text hash value is generated only by the text to be encoded, the second text hash value is also generated only by the target decoded text; when the first text hash value is generated by the combination of the text to be encoded and the encoding check value, the second text hash value is also generated by the combination of the target decoded text and the decoding check value. This ensures the algorithm consistency of the encoding process and the decoding process, and avoids decoding errors caused by inconsistent algorithms.

[0113] The following is an embodiment of a text encoding device provided in an embodiment of the present disclosure. The device and the text encoding methods of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the text encoding device, reference can be made to the embodiments of the above-mentioned text encoding methods.

[0114] Figure 3 FIG. 2 shows a schematic diagram of the structure of a text encoding device provided by an embodiment of the present disclosure. Figure 3 As shown, the text encoding device 300 may include:

[0115] A first information acquisition module 310 is used to acquire a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and the first encoding identifier, and the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and the second encoding identifier;

[0116] The target encoding identifier determination module 320 is used to determine the first target mapping table corresponding to the target character from each preset mapping table based on the first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, and query the first target mapping table based on the target character to determine the target encoding identifier corresponding to the target character;

[0117] The target coded text generation module 330 is used to generate the target coded text based on the target coding identifier corresponding to each target character in the text to be encoded.

[0118] The above-mentioned text encoding device provided by the embodiment of the present disclosure can obtain multiple preset mapping tables for recording the one-to-one mapping relationship between the characters constituting the text and the encoding identifiers according to the reference mapping table in the relevant technology, and select the preset mapping table adapted to the characters to be encoded in the to-be-encoded text from the multiple preset mapping tables according to the mapping table reference sequence, and map the corresponding characters to be encoded to the corresponding target encoding identifiers to obtain the target encoded text; it realizes text encoding and decoding in units of characters, saves the process of word segmentation and building a vocabulary table adapted to the word segmentation method, avoids the problem of text encoding dependence on the word segmentation method and text distortion, and improves text encoding efficiency and text encoding accuracy; in addition, the preset mapping table used for each character is determined by the mapping table reference sequence, which increases the difficulty of cracking the text encoding to a certain extent, thereby improving the security of the text encoding.

[0119] In some embodiments, the number of preset mapping tables is greater than or equal to the cardinality of the counting system of the mapping table reference sequence.

[0120] In some embodiments, the first information acquisition module 310 is specifically used to:

[0121] Performing random sorting or random number calculation on the first coding identifiers included in the reference mapping table to obtain the second coding identifiers;

[0122] Based on the information contained in the reference mapping table and each second coding identifier, a preset mapping table is generated; wherein the information includes each character and / or each first coding identifier.

[0123] In some embodiments, the text encoding apparatus 300 further includes a first reference sequence generating module, which is used to:

[0124] Before determining a first target mapping table corresponding to the target character from each preset mapping table based on a first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, and querying the first target mapping table based on the target character to determine a target encoding identifier corresponding to the target character, determining a mapping table reference sequence based on the text to be encoded;

[0125] Alternatively, before determining the first target mapping table corresponding to the target character from each preset mapping table based on the first arrangement position of the target character in the text to be encoded and the mapping table reference sequence, and querying the first target mapping table based on the target character to determine the target encoding identifier corresponding to the target character, determine the mapping table reference sequence based on the text to be encoded and the encoding check value.

[0126] In some embodiments, the first reference sequence generation module is specifically used to:

[0127] Performing a hash operation on the text to be encoded, or a combination of the text to be encoded and the encoding check value, to generate a first text hash value;

[0128] Based on the first text hash value and the encoding check, a mapping table reference sequence is generated.

[0129] In some embodiments, the encoded check value includes a user identification.

[0130] In some embodiments, the target encoding text generation module 330 is specifically used to:

[0131] Generate a target encoded text based on the target encoding identifier corresponding to each target character in the to-be-encoded text and the first text hash value;

[0132] Alternatively, the target encoded text is generated based on the target encoding identifier corresponding to each target character in the text to be encoded, the first verification hash value and the first text hash value; wherein the first verification hash value is the hash value of the encoding verification value.

[0133] In some embodiments, the target code identification determination module 320 is specifically used to:

[0134] Determining a second arrangement position based on the first arrangement position and a sequence length of a reference sequence in the mapping table;

[0135] A first mapping table identifier at a second arrangement position is determined from the mapping table reference sequence, and a preset mapping table corresponding to the first mapping table identifier is determined as a first target mapping table.

[0136] The text encoding device provided in the embodiments of the present disclosure can execute the text encoding method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0137] The following is an embodiment of a text decoding device provided by an embodiment of the present disclosure. The device and the text decoding methods of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the text decoding device, reference can be made to the embodiment of the above-mentioned text decoding method.

[0138] Figure 4 FIG. 2 shows a schematic diagram of a text decoding device provided by an embodiment of the present disclosure. Figure 4 As shown, the text decoding device 400 may include:

[0139] The second information acquisition module 410 is used to acquire the text to be decoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on the reference mapping table, the reference mapping table is used to record the one-to-one correspondence between the characters constituting the text and the first encoding identifier, and the preset mapping table is used to record the one-to-one correspondence between the information in the reference mapping table and the second encoding identifier;

[0140] The decoding character determination module 420 is used to determine the second target mapping table corresponding to the target coding identifier from each preset mapping table based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, and query the second target mapping table based on the target coding identifier to determine the decoding character corresponding to the target coding identifier;

[0141] The target decoded text generation module 430 is used to generate a target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

[0142] The above-mentioned text decoding device provided by the embodiment of the present disclosure can obtain multiple preset mapping tables for recording the one-to-one mapping relationship between the characters constituting the text and the encoding identifiers according to the reference mapping table in the relevant technology, and select the preset mapping table adapted to the characters to be decoded in the text to be decoded from the multiple preset mapping tables according to the mapping table reference sequence, and map the corresponding characters to be decoded to the corresponding decoding characters to obtain the decoded text; it realizes text encoding and decoding in units of characters, saves the process of word segmentation and building a word table adapted to the word segmentation method, avoids the problem of text encoding dependence on the word segmentation method and text distortion, and improves text encoding efficiency and text encoding accuracy; in addition, the preset mapping table used for each character is determined by the mapping table reference sequence, which increases the difficulty of cracking the text encoding to a certain extent, thereby improving the security of the text encoding.

[0143] In some embodiments, the text to be decoded also includes a first verification hash value and / or a first text hash value; wherein the first verification hash value is the hash value of the encoded verification value, the first text hash value is the hash value of the text to be encoded, or the hash value of the combination of the text to be encoded and the encoded verification value.

[0144] In some embodiments, the text decoding device 400 further includes a first verification module, which is used to:

[0145] In the case where the text to be decoded includes a first verification hash value, after obtaining the text to be decoded and a plurality of preset mapping tables, performing a hash operation on the decoding verification value to generate a second verification hash value;

[0146] When it is determined that the second verification hash value is equal to the first verification hash value, the decoding verification is determined to be successful, and the step of triggering the execution of a second target mapping table corresponding to the target coding identifier from each preset mapping table based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, and querying the second target mapping table based on the target coding identifier to determine the decoding character corresponding to the target coding identifier.

[0147] In some embodiments, the text decoding apparatus 400 further includes a second reference sequence generating module, which is used to:

[0148] In the case where the text to be decoded includes a first text hash value, based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, a second target mapping table corresponding to the target coding identifier is determined from each preset mapping table, and the second target mapping table is queried based on the target coding identifier to determine the decoding character corresponding to the target coding identifier, and before a mapping table reference sequence is generated based on the first text hash value and the decoding check value.

[0149] In some embodiments, the text decoding device 400 further includes a second verification module for:

[0150] In the case where the text to be decoded includes the first text hash value, after generating a target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded, performing a hash operation on the target decoded text, or a combination of the target decoded text and the decoding check value, to generate a second text hash value;

[0151] In the case where it is determined that the second text hash value is equal to the first text hash value, it is determined that the text decoding is successful.

[0152] In some embodiments, the decoded character determination module 420 is specifically used to:

[0153] Determining a fourth arrangement position based on the third arrangement position and a sequence length of a reference sequence in the mapping table;

[0154] A second mapping table identifier at a fourth arrangement position is determined from the mapping table reference sequence, and a preset mapping table corresponding to the second mapping table identifier is determined as a second target mapping table.

[0155] The text decoding device provided in the embodiments of the present disclosure can execute the text decoding method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0156] It is worth noting that in the embodiments of the above-mentioned devices, the modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present disclosure.

[0157] The present disclosure also provides an electronic device, which may include a processor and a memory, wherein the memory may be used to store executable instructions, wherein the processor may be used to read the executable instructions from the memory and execute the executable instructions to implement the text encoding method or text decoding method in any of the above embodiments.

[0158] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.

[0159] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the information processing device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output interface (I / O interface) 505 is also connected to the bus 504.

[0160] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data.

[0161] It should be noted that Figure 5 The electronic device 500 shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure. Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0162] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the text encoding method or text decoding method of any embodiment of the present disclosure are executed.

[0163] An embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the text encoding method or text decoding method in any embodiment of the present disclosure.

[0164] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0165] In some embodiments, the client and server may communicate using any currently known or future developed network protocol such as HTTP, and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0166] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0167] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the text encoding method or text decoding method described in any embodiment of the present disclosure.

[0168] In embodiments of the present disclosure, computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0169] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0170] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0171] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0172] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0173] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0174] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A text encoding method, characterized in that: include: Obtain a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first coding identifier, the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and a second coding identifier, the preset mapping table is generated based on the information contained in the reference mapping table and each of the second coding identifiers, the information includes each of the characters and / or each of the first coding identifiers, and the second coding identifier is generated based on random sorting or random number calculation of each of the first coding identifiers contained in the reference mapping table; Based on a first arrangement position of a target character in the text to be encoded in the text to be encoded and a mapping table reference sequence, a first target mapping table corresponding to the target character is determined from each of the preset mapping tables, and the first target mapping table is queried based on the target character to determine a target encoding identifier corresponding to the target character; wherein the mapping table reference sequence is generated based on the text to be encoded; or, the mapping table reference sequence is generated based on the text to be encoded and an encoding check value; A target encoded text is generated based on the target encoding identifier corresponding to each target character in the text to be encoded.

2. The method according to claim 1, characterized in that The number of the preset mapping tables is greater than or equal to the cardinality of the counting system of the mapping table reference sequence.

3. The method according to claim 1, characterized in that Acquiring the preset mapping table includes: Performing random sorting or random number calculation on each of the first coding identifiers included in the reference mapping table to obtain each second coding identifier; The preset mapping table is generated based on the information contained in the reference mapping table and each of the second encoding identifiers.

4. The method according to claim 1, characterized in that: Before determining the first target mapping table corresponding to the target character from each of the preset mapping tables based on the first arrangement position of the target character in the text to be encoded in the text to be encoded and the mapping table reference sequence, and querying the first target mapping table based on the target character to determine the target encoding identifier corresponding to the target character, the method further includes: Based on the text to be encoded, determining the mapping table reference sequence; Alternatively, the mapping table reference sequence is determined based on the text to be encoded and the encoding check value.

5. The method according to claim 4, characterized in that The determining the mapping table reference sequence based on the to-be-encoded text and the encoding check value comprises: Performing a hash operation on the text to be encoded, or a combination of the text to be encoded and the encoding check value, to generate a first text hash value; Based on the first text hash value and the encoding check, the mapping table reference sequence is generated.

6. The method according to claim 4, characterized in that The encoded check value includes a user identifier.

7. The method according to claim 5, characterized in that The generating the target coded text based on the target coding identifier corresponding to each target character in the to-be-coded text comprises: Generate the target encoded text based on the target encoding identifier corresponding to each target character in the to-be-encoded text and the first text hash value; Alternatively, the target encoded text is generated based on the target encoding identifier corresponding to each target character in the text to be encoded, the first verification hash value and the first text hash value; wherein the first verification hash value is the hash value of the encoding verification value.

8. The method according to claim 1, characterized in that: The determining, based on the first arrangement position of the target character in the text to be encoded in the text to be encoded and the mapping table reference sequence, from each of the preset mapping tables a first target mapping table corresponding to the target character comprises: Determining a second arrangement position based on the first arrangement position and a sequence length of a reference sequence in the mapping table; A first mapping table identifier at the second arrangement position is determined from the mapping table reference sequence, and the preset mapping table corresponding to the first mapping table identifier is determined as the first target mapping table.

9. A text decoding method, characterized in that: include: Obtain a text to be decoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first coding identifier, the preset mapping table is used to record a one-to-one correspondence between information in the reference mapping table and a second coding identifier, the preset mapping table is generated based on the information contained in the reference mapping table and each of the second coding identifiers, the information includes each of the characters and / or each of the first coding identifiers, and the second coding identifier is generated based on random sorting or random number calculation of each of the first coding identifiers contained in the reference mapping table; Based on the third arrangement position of the target coding identifier in the text to be decoded in the text to be decoded and the mapping table reference sequence, a second target mapping table corresponding to the target coding identifier is determined from each of the preset mapping tables, and the second target mapping table is queried based on the target coding identifier to determine the decoding character corresponding to the target coding identifier, wherein the text to be decoded also includes a first verification hash value and / or a first text hash value; the first text hash value is a hash value of the text to be encoded, or a hash value of a combination of the text to be encoded and the encoding verification value; the mapping table reference sequence is generated based on the first text hash value and the decoding verification value; A target decoded text is generated based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

10. The method according to claim 9, characterized in that The first verification hash value is a hash value of the encoded verification value.

11. The method according to claim 10, characterized in that In the case where the text to be decoded includes the first verification hash value, after obtaining the text to be decoded and a plurality of preset mapping tables, the method further includes: Performing a hash operation on the decoded check value to generate a second check hash value; When it is determined that the second verification hash value is equal to the first verification hash value, the decoding verification is determined to be successful, and the step of determining the second target mapping table corresponding to the target coding identifier in the text to be decoded based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence in each of the preset mapping tables is triggered, and the second target mapping table is queried based on the target coding identifier to determine the decoding character corresponding to the target coding identifier.

12. The method according to claim 10, characterized in that In the case where the text to be decoded includes the first text hash value, before determining the second target mapping table corresponding to the target coding identifier in the text to be decoded based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence in the text to be decoded, and querying the second target mapping table based on the target coding identifier to determine the decoding character corresponding to the target coding identifier, the method further includes: The mapping table reference sequence is generated based on the first text hash value and the decoding check value.

13. The method according to claim 10, characterized in that In the case where the text to be decoded includes the first text hash value, after generating the target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded, the method further includes: Performing a hash operation on the target decoded text, or a combination of the target decoded text and a decoding check value, to generate a second text hash value; When it is determined that the second text hash value is equal to the first text hash value, it is determined that the text decoding is successful.

14. The method according to claim 9, characterized in that The determining, based on the third arrangement position of the target coding identifier in the text to be decoded and the mapping table reference sequence, from each of the preset mapping tables, the second target mapping table corresponding to the target coding identifier comprises: Determining a fourth arrangement position based on the third arrangement position and a sequence length of the reference sequence in the mapping table; A second mapping table identifier at the fourth arrangement position is determined from the mapping table reference sequence, and the preset mapping table corresponding to the second mapping table identifier is determined as the second target mapping table.

15. A text encoding device, characterized in that: include: A first information acquisition module, used to acquire a text to be encoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first coding identifier, the preset mapping table is used to record a one-to-one correspondence between the information in the reference mapping table and a second coding identifier, the preset mapping table is generated based on the information contained in the reference mapping table and each of the second coding identifiers, the information includes each of the characters and / or each of the first coding identifiers, and the second coding identifier is generated based on random sorting or random number calculation of each of the first coding identifiers contained in the reference mapping table; A target encoding identifier determination module is used to determine a first target mapping table corresponding to the target character in the text to be encoded from each of the preset mapping tables based on a first arrangement position of the target character in the text to be encoded and a mapping table reference sequence, and query the first target mapping table based on the target character to determine a target encoding identifier corresponding to the target character; wherein the mapping table reference sequence is generated based on the text to be encoded; or the mapping table reference sequence is generated based on the text to be encoded and a coding check value; The target coded text generation module is used to generate the target coded text based on the target coding identifier corresponding to each target character in the text to be encoded.

16. A text decoding device, characterized in that: include: A second information acquisition module, used to acquire a text to be decoded and a plurality of preset mapping tables; wherein the preset mapping table is generated based on a reference mapping table, the reference mapping table is used to record a one-to-one correspondence between characters constituting the text and a first coding identifier, the preset mapping table is used to record a one-to-one correspondence between the information in the reference mapping table and the second coding identifier, the preset mapping table is generated based on the information contained in the reference mapping table and each of the second coding identifiers, the information includes each of the characters and / or each of the first coding identifiers, and the second coding identifier is generated based on random sorting or random number calculation of each of the first coding identifiers contained in the reference mapping table; A decoding character determination module, for determining a second target mapping table corresponding to the target coding identifier in the text to be decoded from each of the preset mapping tables based on a third arrangement position of the target coding identifier in the text to be decoded and a mapping table reference sequence, and querying the second target mapping table based on the target coding identifier to determine a decoding character corresponding to the target coding identifier, wherein the text to be decoded also includes a first verification hash value and / or a first text hash value; the first text hash value is a hash value of the text to be encoded, or a hash value of a combination of the text to be encoded and the encoding verification value; the mapping table reference sequence is generated based on the first text hash value and the decoding verification value; The target decoded text generation module is used to generate a target decoded text based on the decoding characters corresponding to each target encoding identifier in the text to be decoded.

17. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the text encoding method described in any one of claims 1 to 8 or the text decoding method described in any one of claims 9 to 14.

18. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the text encoding method described in any one of claims 1 to 8 or the text decoding method described in any one of claims 9 to 14.

Citation Information

Patent Citations

  • Tag creation method and apparatus, electronic device and medium

    WO2021196468A1