CN111475543A - Fuzzy search method and device, computer equipment and storage medium - Google Patents

Fuzzy search method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111475543A
CN111475543A CN202010229002.3A CN202010229002A CN111475543A CN 111475543 A CN111475543 A CN 111475543A CN 202010229002 A CN202010229002 A CN 202010229002A CN 111475543 A CN111475543 A CN 111475543A
Authority
CN
China
Prior art keywords
ciphertext
plaintext information
character
characters
searched
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010229002.3A
Other languages
Chinese (zh)
Inventor
严月强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN202010229002.3A priority Critical patent/CN111475543A/en
Publication of CN111475543A publication Critical patent/CN111475543A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2468Fuzzy queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes

Abstract

The invention discloses a fuzzy search method, a fuzzy search device, computer equipment and a storage medium, wherein the fuzzy search method comprises the following steps: acquiring plaintext information to be stored; splitting a plurality of characters of plaintext information to be stored one by one to obtain a plurality of independent first characters; searching a ciphertext corresponding to each first character in a ciphertext database; combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to plaintext information to be stored; storing the first ciphertext string in a target database; when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction; and carrying out fuzzy search from the target database to obtain a fuzzy search result of the plaintext information to be searched. And encrypting the plaintext information to be searched to obtain a second ciphertext string corresponding to the plaintext information to be searched, and only performing fuzzy search from the target database by using the second ciphertext string, so that the searching efficiency is improved.

Description

Fuzzy search method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of information security technologies, and in particular, to a fuzzy search method and apparatus, a computer device, and a storage medium.
Background
In general, in order to protect personal privacy or prevent important information from being leaked, plaintext information to be kept secret is usually encrypted and stored in a database, so that even if the information is leaked, an attacker can hardly crack and take the plaintext information without knowing a key.
However, the way of performing fuzzy search on the data stored in the database after being encrypted by the codes needs to read out the full data from the database, decrypt the full data and search through the data, and the fuzzy search method has extremely poor code performance, occupies a lot of resources, and causes low search efficiency.
Disclosure of Invention
The invention provides a fuzzy search method, a fuzzy search device, computer equipment and a storage medium, which are used for solving the problem of fuzzy search.
A fuzzy search method comprising:
acquiring plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters;
splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
searching a ciphertext corresponding to each first character in a ciphertext database;
combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to the plaintext information to be stored;
storing the first ciphertext string in a target database;
when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters;
splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
searching a ciphertext corresponding to each second character in the ciphertext database;
combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be stored;
and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
A fuzzy search apparatus comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module acquires plaintext information to be stored, and the plaintext information to be stored comprises a plurality of characters;
the first splitting module is used for splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
the first searching module searches a ciphertext corresponding to each first character in a ciphertext database;
the first combination module is used for combining the ciphertexts corresponding to all the first characters to obtain a first cipher text string corresponding to the plaintext information to be stored;
the storage module stores the first ciphertext string into a target database;
the device comprises an analyzing module, a searching module and a searching module, wherein the analyzing module analyzes plaintext information to be searched from a searching instruction when the searching instruction containing the plaintext information to be searched is acquired, and the plaintext information to be searched comprises a plurality of characters;
the second splitting module is used for splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
the second searching module searches the ciphertext corresponding to each second character in the ciphertext database;
the second combination module is used for combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and the fuzzy search module is used for performing fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the fuzzy search method when executing the computer program.
A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned fuzzy search method.
According to the fuzzy search method, the fuzzy search device, the computer equipment and the storage medium, in one scheme, all first characters are combined to obtain a first ciphertext string, the first ciphertext string is stored in a target database, when a search instruction containing plaintext information to be searched is obtained, the plaintext information to be searched is analyzed from the search instruction, the plaintext information to be searched is encrypted according to the same method for obtaining the first ciphertext string, a second ciphertext string corresponding to the plaintext information to be searched is obtained, when fuzzy search is carried out, only the second ciphertext string is used for carrying out fuzzy search from the target database, the whole data does not need to be loaded into an internal memory and then code logic fuzzy search is carried out, the occupied resources are small, and therefore the search efficiency is improved.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the description of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a diagram illustrating an application environment of a fuzzy search method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a fuzzy search method according to an embodiment of the present invention;
FIG. 3 is another flow chart of a fuzzy search method in an embodiment of the present invention;
FIG. 4 is another flow chart of a fuzzy search method in an embodiment of the present invention;
FIG. 5 is another flow chart of a fuzzy search method in an embodiment of the present invention;
FIG. 6 is a schematic block diagram of an embodiment of the fuzzy search apparatus;
FIG. 7 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The fuzzy search method provided by the invention can be applied to the application environment shown in fig. 1, wherein a server communicates with a client through a network.
The fuzzy search method comprises the following steps: acquiring plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters; splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters; searching a ciphertext corresponding to each first character in a ciphertext database; combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to the plaintext information to be stored; storing the first ciphertext string in a target database; when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters; splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters; searching a ciphertext corresponding to each second character in the ciphertext database; combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched; and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched. Among other things, the client may be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The client can be a smart phone, and a user sends a search instruction of plaintext information to be searched through a network by using the smart phone. The server can be implemented by an independent server or a server cluster composed of a plurality of servers.
In an embodiment, as shown in fig. 2, a fuzzy search method is provided, which is described by taking the server in fig. 1 as an example, and includes the following steps:
s10: the method comprises the steps of obtaining plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters.
The plaintext information to be stored refers to words, numbers, character strings or the like which are not encrypted, for example, the plaintext information to be stored is a string of character strings "abcd", wherein the characters of the plaintext information to be stored include "a", "b", "c" and "d".
S20: and splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters.
The first character refers to a single Chinese character, a single number or a single character after the plaintext information to be stored is split, for example, the first character obtained by splitting a plurality of characters of the plaintext information to be stored one by one is "a", "b", "c" or "d".
S30: and searching a ciphertext corresponding to each first character in a ciphertext database.
The ciphertext database is a database storing a single chinese character, a single number, or a ciphertext corresponding to a single character, and the ciphertext database is searched for a ciphertext corresponding to each first character, for example, the ciphertext of "a" is "/FFAIT L inFmuEYIby +8qtw ═ the ciphertext of" b "is" 5XQBeK6AZMhWuWdvslw65A ═ the ciphertext of "c" is "uxRV 6buP + q L lshun 2 nsjikg ═ and the ciphertext of" d "is" bocnqvipdcr 4f2zrvIKU8w ═ the ciphertext of "b.
S40: and combining the ciphertexts corresponding to all the first characters to obtain a first cipher text string corresponding to the plaintext information to be stored.
In an embodiment, in step S40, that is, the ciphertext corresponding to all the first characters is combined to obtain the first ciphertext string corresponding to the plaintext information to be stored. The method comprises the following steps:
s41: and encrypting, splicing and combining ciphertexts corresponding to all the first characters in sequence by adopting preset characters to obtain a first cipher text string corresponding to the plaintext information to be stored.
For example, when the plaintext information to be stored is "abcd", the first characters corresponding to "a", "b", "c", and "d" are combined, and then ciphertext strings corresponding to "/FFAIT L inFmuEYIby +8qtw ═ 5XQBeK6 azhwuwuwdvslwslw 65A ═ CnBoQVipDCr4 buP + q L l sllun 2nsjKg ═ CnBoQVipDCr4f2zrvIKU8w ═ are obtained.
In the embodiment, the ciphertexts corresponding to all the first characters are encrypted and spliced by adopting the preset characters in sequence, so that an illegal user cannot decrypt the encrypted content of the first cipher text string even if the illegal user cracks the mobile terminal and obtains the first cipher text string, thereby protecting the content of the plaintext information to be stored and improving the safety of the plaintext information to be stored.
S50: and storing the first ciphertext string in a target database.
For example, a ciphertext string having a first ciphertext string "/FFAIT L inFmuEYIby +8qtw ═ 5XQBeK6 azmthwuwdvslw 65A ═ uxRV6buP + q L lsun 2nsjKg ═ CnBoQVipDCr4f2zr iku8w ═ is stored in the target database.
S60: when a search instruction containing plaintext information to be searched is acquired, the plaintext information to be searched is analyzed from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters.
The plaintext information to be searched refers to encrypted words, numbers or character strings which need to be subjected to fuzzy search, for example, the plaintext information to be searched is "bc", wherein the characters for searching the plaintext information comprise "b" and "c".
S70: and splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters.
The second character is a single Chinese character, a single number or a single character after the plaintext information to be searched is split. For example, the second characters obtained by splitting a plurality of characters of plaintext information to be searched one by one are "b" and "c".
S80: and searching a ciphertext corresponding to each second character in the ciphertext database.
The ciphertext database is searched for the ciphertext corresponding to each second character, for example, the ciphertext of "b" is "5 XQBeK6AZMhWuWdvslw65A ═ and the ciphertext of" c "is" uxRV6buP + q L lSlun2nsjKg ═ respectively.
S90: and combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched.
And encrypting, splicing and combining the ciphertexts corresponding to all the second characters in sequence by adopting preset characters to obtain a second ciphertext string corresponding to the combined plaintext information to be searched.
For example, the second character corresponding to the plaintext information to be searched is "bc" and is ciphertext corresponding to "b" and "c", and then the ciphertext string corresponding to "bc" is obtained as "5 XQBeK6 mzhwudvslw 65A ═ uxRV6buP + q L lSlun2nsjKg ═ by combining.
S100: and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
The fuzzy search result means that the system allows a certain difference between the plaintext information to be stored and the plaintext information to be searched, the ciphertext string corresponding to the second ciphertext string is obtained from the target database, the plaintext information corresponding to the plaintext information to be searched is obtained from the target database, the ciphertext string corresponding to the second ciphertext string is decrypted by the encryption method, specifically, the ciphertext of the second ciphertext string is split one by one to obtain a plurality of ciphertexts corresponding to the second ciphertext string, the second character corresponding to the ciphertext corresponding to each of the second ciphertext string is searched from the ciphertext database, the fuzzy ciphertext string corresponding to the plurality of second ciphertext strings is combined to obtain the fuzzy ciphertext information corresponding to the second ciphertext string, the fuzzy ciphertext string corresponding to the fuzzy ciphertext string is obtained from the plaintext additionally 36598, the plaintext additionally 3648 is obtained from the plaintext additionally 3655, the plaintext string corresponding to the target plaintext string 3635, the plaintext additionally 3648, the fuzzy ciphertext string corresponding to the fuzzy ciphertext string is stored, the target plaintext information aidcpiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipii, the plaintext string is obtained from the plaintext information additionally from the plaintext string 368, the plaintext information additionally 368, the plaintext string corresponding to the target database, the plaintext string is obtained from the plaintext information 7, the plaintext pefxpiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqipiqi.
In the embodiment corresponding to fig. 2, the characters of the plaintext information to be stored are firstly split one by one, then a plurality of separate ciphertexts corresponding to the second characters are searched from a cipher text database, and finally the ciphertexts corresponding to the first characters are encrypted, spliced and combined in sequence by adopting preset characters, so that the plaintext information to be stored can be encrypted. The first ciphertext string is stored in a target database, when a search instruction containing plaintext information to be searched is obtained, the plaintext information to be searched is analyzed from the search instruction, the plaintext information to be searched is encrypted, namely the plaintext information to be searched is encrypted according to the same method for obtaining the first ciphertext string, a second ciphertext string corresponding to the plaintext information to be searched is obtained, when fuzzy search is carried out, only the second ciphertext string is used for carrying out fuzzy search from the target database, the whole data does not need to be loaded into a memory for code logic fuzzy search, the occupied resources are less, and therefore the search efficiency is improved.
In an embodiment, as shown in fig. 3, after S20 before step S10, that is, after the plaintext information to be stored is obtained, the following steps are further included:
s111: and acquiring a first field name corresponding to the plaintext information to be stored from the field database table.
The first field name is the name of the same kind of information corresponding to the plaintext information to be stored, and the field database is a database in which a plurality of field names are stored. For example, the first field name corresponding to the plaintext information "abcd" to be stored is "name".
S112: and searching whether a key corresponding to the first field name exists in a key issuing system.
The key issuing system stores keys corresponding to field names, and different field names correspond to different keys. And searching whether a key corresponding to the first field name' exists in a key issuing system.
S113: and if the key corresponding to the first field name is found in the key issuing system, obtaining the key corresponding to the first field name.
The key is a parameter that is input in a ciphertext corresponding to conversion of a field name into a field name. For example, if the key "aaaaaaaaaaaaaaaa" corresponding to the first field name "is found in the key issuing system, the key" aaaaaaaaaaaaaaaa "corresponding to the first field name is obtained.
S114: and if the key corresponding to the first field name cannot be searched in the key issuing system, randomly generating the key corresponding to the first field name.
If the key corresponding to the first field name ' cannot be found in the key issuing system, randomly generating the key corresponding to the first field name ' aaaaaaaaaaaaaaaa '.
Further, a key "aaaaaaaaaaaaaaaa" corresponding to the first field name is stored in the key issuing system.
In step S30, that is, the searching for the ciphertext corresponding to each of the first characters in the ciphertext database includes the following steps:
s31: and searching whether a ciphertext corresponding to each first character exists in the ciphertext database by taking the combination of the first field name and the first character as an identifier.
The ciphertext database may be a redis cache, which may serve as a database, cache, and message middleware.
And splicing and combining the first field name and the first character in sequence by adopting preset characters, wherein the preset characters are marked lines _', and the first field name _ first character is obtained. For example, if the first field name is "name", the first character is "a", "b", "c", "d", and the combination of the first field name and the first character is "name _ a", "name _ b", "name _ c", "name _ d".
And searching whether the ciphertext corresponding to the 'a' exists in the redis cache by taking the 'name _ a' as an identifier, namely taking the 'name _ a' as a key. Similarly, "name _ b", "name _ c", "name _ d" also find the ciphertext according to the above-mentioned manner.
S32: and if the ciphertext corresponding to the first character is found in the ciphertext database, obtaining the ciphertext corresponding to the first character.
If the ciphertext corresponding to the first character "a" is found in the redis cache in the form of "/FFAIT L inFmuEYIby +8qtw ═ then the ciphertext corresponding to the first character" a "is obtained in the form of"/FFAIT L inFmuEYIby +8qtw ═ b ".
Similarly, if the ciphertext corresponding to the first character "b" is found in the redis cache as "5 XQBeK6AZMhWuWdvslw65A ═", then the ciphertext corresponding to the first character "b" is obtained as "5 XQBeK6AZMhWuWdvslw65A ═", and similarly, the ciphertext corresponding to the first character "c" is obtained as "uxRV 6buP + q L lshun 2nsjKg ═", and the ciphertext corresponding to the first character "d" is obtained as "CnBoQVipDCr 4f2zrvIKU8w ═".
S33: if the ciphertext corresponding to the first character cannot be found in the ciphertext database, an encryption algorithm is adopted, a key corresponding to the first field name is used as a key, and the first character is encrypted, so that the ciphertext corresponding to the encrypted first character is obtained.
If the ciphertext corresponding to the first character "a" is not found in the redis cache, an Encryption algorithm, for example, an Advanced Encryption Standard (AES) Encryption algorithm may be used, and the first character "a" is encrypted by using the key "aaaaaaaaaaaaaaaa" corresponding to the first field name "as a key, so as to obtain the ciphertext"/FFAIT L inFmuEYIby +8qtw ═ corresponding to the encrypted first character "a".
Further, a ciphertext "/FFAIT L inFmuEYIby +8qtw ═ corresponding to the first character" a "is stored in the redis cache, where the first character" a "is an identifier (key), and the ciphertext"/FFAIT L inFmuEYIby +8qtw ═ is a value (value).
Similarly, if the ciphertext corresponding to the first character "b", "c", or "d" cannot be found in the redis cache, the ciphertext corresponding to the first character "b", "c", or "d" is obtained in a manner.
In the embodiment corresponding to fig. 3, first, whether a key corresponding to the first field name exists is searched in a key issuing system, and different field names correspond to different encryption keys, so that even if an illegal user cracks a mobile terminal and obtains a first field, the key corresponding to the first field cannot be further obtained, which increases the difficulty of decryption by the illegal user, and then, a ciphertext corresponding to the first character is searched in a ciphertext database by using a combination of the first field name and the first character as an identifier, so that the security performance of the obtained ciphertext corresponding to the first character is higher, and the security of the ciphertext corresponding to the first character is improved.
In an embodiment, as shown in fig. 4, after step S60, the method further includes the following steps:
s121: and acquiring a second field name corresponding to plaintext information to be searched.
The second field name is the name of the same kind of information corresponding to the plaintext information to be searched in the field database table. Specifically, the second field name corresponding to the search plaintext information "bc" is acquired as "name".
S122: and searching the key corresponding to the second field name in the key issuing system to obtain the key corresponding to the second field name.
For example, if the key "aaaaaaaaaaaaaaaa" corresponding to the second field name "is found in the key issuing system, the key" aaaaaaaaaaaaaaaa "corresponding to the second field name is obtained.
In step S80, that is, searching the ciphertext database for the ciphertext corresponding to each of the second characters, the method includes the following steps:
s81: and searching whether a ciphertext corresponding to the second character exists in a ciphertext database by taking the combination of the key corresponding to the second field name and the second character as an identifier.
And splicing and combining the second field name and the second character in sequence by adopting preset characters, wherein the preset characters are marked lines _', and the second field name _ second character is obtained. For example, if the second field name is "name", the second character is "b" or "c", and the combination of the second field name and the second character is "name _ b" or "name _ c".
And searching whether the ciphertext corresponding to the 'b' exists in the redis cache by taking the 'name _ b' as an identifier, namely taking the 'name _ b' as a key. Similarly, "name _ c" is also used to search for the ciphertext according to the above-mentioned manner.
S82: and if the ciphertext corresponding to the second character is found in the ciphertext database, obtaining the ciphertext corresponding to the second character.
The ciphertext database may be a redis cache, which may serve as a database, cache, and message middleware. If the ciphertext corresponding to the second character "b" is found in the redis cache as "5 XQBeK6AZMhWuWdvslw65A ═", then the ciphertext corresponding to the second character "b" is obtained as "5 XQBeK6AZMhWuWdvslw65A ═".
S83: and if the ciphertext corresponding to the second character cannot be searched in the ciphertext database, encrypting the second character by adopting an encryption algorithm and taking the key corresponding to the second field name as a key to obtain the ciphertext corresponding to the encrypted second character.
If the ciphertext corresponding to the second character "b" cannot be searched in the redis cache, an Advanced Encryption Standard (AES) encryption algorithm is adopted, a key "aaaaaaaaaaaaaaaa" corresponding to the second field name "is used as a key, and the second character" b "is encrypted, so that the ciphertext" 5XQBeK6AZMhWuWdvslw65A ═ corresponding to the encrypted second character "b" is obtained.
Similarly, if the ciphertext corresponding to the second character "c" cannot be found in the redis cache, the ciphertext corresponding to the second character "c" is obtained in a manner.
In the embodiment corresponding to fig. 4, the key corresponding to the second field name is first searched in the key issuing system, the key corresponding to the second field name is obtained, different field names correspond to different encryption keys, an illegal user cannot further obtain the key corresponding to the second field name even if the illegal user cracks the mobile terminal and obtains the second field name, and then the combination of the key corresponding to the second field name and the second character is used as an identifier, so that the second character found in the ciphertext database corresponds to different ciphertexts, and therefore, the obtained ciphertext corresponding to the second character has higher security performance, and the security of the ciphertext is improved.
In one embodiment, as shown in FIG. 5:
s131: performing fuzzy search on the plaintext information to be searched and packaging the process of obtaining a fuzzy search result after receiving a search instruction containing the plaintext information to be searched in the step by adopting an Aspect Organized Programming (AOP) Oriented annotation mode, namely packaging the steps S60-S100 to form a search function block and adding annotation information;
s132: and when a search calling instruction sent by a third party is received, executing a search function block corresponding to the annotation information according to the search calling instruction.
In the embodiment corresponding to fig. 5, an AOP annotation mode is introduced into the fuzzy search method, plaintext information to be searched in the fuzzy search method is converted into ciphertext, then fuzzy search is performed through a target database, the obtained fuzzy search result is encapsulated by a method, the search function block is encapsulated and added with annotation information, when a search call instruction sent by a third party is received, the search function block corresponding to the annotation information is executed according to the search call instruction, and the search function block can be directly returned to a calling party. Therefore, a large amount of repeated codes can be avoided in subsequent iterative development, and a fuzzy search result is obtained at zero cost.
It should be understood that, the sequence numbers of the steps in the above embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the present invention.
In one embodiment, a fuzzy search apparatus is provided, and the fuzzy search apparatus corresponds to the fuzzy search methods in the above embodiments one to one. As shown in fig. 6, the fuzzy search apparatus includes an obtaining module 10, a first splitting module 20, a first searching module 30, a first combining module 40, a storing module 50, a parsing module 60, a second splitting module 70, a second searching module 80, a second combining module 90, and a fuzzy search module 100. The functional modules are explained in detail as follows:
the device comprises an acquisition module 10, a storage module and a processing module, wherein the acquisition module acquires plaintext information to be stored, and the plaintext information to be stored comprises a plurality of characters;
the first splitting module 20 is configured to split the multiple characters of the plaintext information to be stored one by one to obtain multiple individual first characters;
the first searching module 30 searches a ciphertext corresponding to each first character in a ciphertext database;
and the first combination module 40 is configured to combine the ciphertexts corresponding to all the first characters to obtain a first cipher text string corresponding to the plaintext information to be stored.
The storage module 50 stores the first ciphertext string in a target database;
the parsing module 60 is configured to parse plaintext information to be searched from a search instruction when the search instruction including the plaintext information to be searched is acquired, where the plaintext information to be searched includes a plurality of characters;
the second splitting module 70 is configured to split the characters of the plaintext information to be searched one by one to obtain a plurality of separate second characters;
a second searching module 80, configured to search the ciphertext database for the ciphertext corresponding to each second character;
the second combining module 90 combines the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and the fuzzy search module 100 performs fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
For the specific limitation of the fuzzy search device, reference may be made to the above limitation of the fuzzy search method, and details are not repeated here. The modules in the fuzzy search device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, as shown in fig. 7, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters;
splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
searching a ciphertext corresponding to each first character in a ciphertext database;
combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to the plaintext information to be stored;
storing the first ciphertext string in a target database;
when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters;
splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
searching a ciphertext corresponding to each second character in the ciphertext database;
combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
acquiring plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters;
splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
searching a ciphertext corresponding to each first character in a ciphertext database;
combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to the plaintext information to be stored;
storing the first ciphertext string in a target database;
when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters;
splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
searching a ciphertext corresponding to each second character in the ciphertext database;
combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
It will be understood by those of ordinary skill in the art that all or a portion of the processes of the methods of the embodiments described above may be implemented by a computer program that may be stored on a non-volatile computer-readable storage medium, which when executed, may include the processes of the embodiments of the methods described above, wherein any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A fuzzy search method, comprising:
acquiring plaintext information to be stored, wherein the plaintext information to be stored comprises a plurality of characters;
splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
searching a ciphertext corresponding to each first character in a ciphertext database;
combining ciphertexts corresponding to all the first characters to obtain a first ciphertext string corresponding to the plaintext information to be stored;
storing the first ciphertext string in a target database;
when a search instruction containing plaintext information to be searched is acquired, analyzing the plaintext information to be searched from the search instruction, wherein the plaintext information to be searched comprises a plurality of characters;
splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
searching a ciphertext corresponding to each second character in the ciphertext database;
combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and carrying out fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
2. The fuzzy search method of claim 1, wherein after said obtaining plaintext information to be stored, said method further comprises:
acquiring a first field name corresponding to plaintext information to be stored from a field database table;
searching whether a key corresponding to the first field name exists in a key issuing system;
if the key corresponding to the first field name is found in the key issuing system, the key corresponding to the first field name is obtained;
if the key corresponding to the first field name cannot be searched in the key issuing system, the key corresponding to the first field name is randomly generated;
the searching the ciphertext corresponding to each first character in the ciphertext database comprises:
using the combination of the first field name and the first character as an identifier, and searching whether a ciphertext corresponding to each first character exists in a ciphertext database;
if the ciphertext corresponding to the first character is found in the ciphertext database, obtaining the ciphertext corresponding to the first character;
if the ciphertext corresponding to the first character cannot be found in the ciphertext database, an encryption algorithm is adopted, a key corresponding to the first field name is used as a key, and the first character is encrypted, so that the ciphertext corresponding to the encrypted first character is obtained.
3. The fuzzy search method of claim 1, wherein said combining the ciphertexts corresponding to all the first characters to obtain the first ciphertext string corresponding to the plaintext information to be stored comprises:
and encrypting, splicing and combining ciphertexts corresponding to all the first characters in sequence by adopting preset characters to obtain a first cipher text string corresponding to the plaintext information to be stored.
4. The fuzzy search method of claim 3, further comprising, after said parsing out said plaintext information to be searched from said search instruction, the steps of:
acquiring a second field name corresponding to plaintext information to be searched;
searching a key corresponding to the second field name in a key issuing system to obtain a key corresponding to the second field name;
searching the ciphertext database for the ciphertext corresponding to each second character, including:
searching whether a ciphertext corresponding to the second character exists in the ciphertext database by taking the combination of the key corresponding to the second field name and the second character as an identifier;
if the ciphertext corresponding to the second character is found in the ciphertext database, obtaining the ciphertext corresponding to the second character;
and if the ciphertext corresponding to the second character cannot be searched in the ciphertext database, encrypting the second character by adopting an encryption algorithm and taking the key corresponding to the second field name as a key to obtain the ciphertext corresponding to the encrypted second character.
5. The fuzzy search method according to any one of claims 1 to 4, wherein after receiving a search instruction containing plaintext information to be searched in a section-oriented programming AOP annotation manner, performing fuzzy search on the plaintext information to be searched and performing a process of obtaining a fuzzy search result by encapsulating the process into a search function block and adding annotation information;
and when a search calling instruction sent by a third party is received, executing a search function block corresponding to the annotation information according to the search calling instruction.
6. A fuzzy search apparatus, comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module acquires plaintext information to be stored, and the plaintext information to be stored comprises a plurality of characters;
the first splitting module is used for splitting the plurality of characters of the plaintext information to be stored one by one to obtain a plurality of independent first characters;
the first searching module searches a ciphertext corresponding to each first character in a ciphertext database;
the first combination module is used for combining the ciphertexts corresponding to all the first characters to obtain a first cipher text string corresponding to the plaintext information to be stored;
the storage module stores the first ciphertext string into a target database;
the device comprises an analyzing module, a searching module and a searching module, wherein the analyzing module analyzes plaintext information to be searched from a searching instruction when the searching instruction containing the plaintext information to be searched is acquired, and the plaintext information to be searched comprises a plurality of characters;
the second splitting module is used for splitting the characters of the plaintext information to be searched one by one to obtain a plurality of independent second characters;
the second searching module searches the ciphertext corresponding to each second character in the ciphertext database;
the second combination module is used for combining the ciphertexts corresponding to all the second characters to obtain a second cipher text string corresponding to the plaintext information to be searched;
and the fuzzy search module is used for performing fuzzy search from the target database by using the second ciphertext string to obtain a fuzzy search result of the plaintext information to be searched.
7. The fuzzy search apparatus of claim 6, further comprising, after said obtaining module:
acquiring a first field name corresponding to plaintext information to be stored from a field database table;
searching whether a key corresponding to the first field name exists in a key issuing system;
if the key corresponding to the first field name is found in the key issuing system, the key corresponding to the first field name is obtained;
if the key corresponding to the first field name cannot be searched in the key issuing system, the key corresponding to the first field name is randomly generated;
the first search module is specifically configured to:
using the combination of the first field name and the first character as an identifier, and searching whether a ciphertext corresponding to each first character exists in a ciphertext database;
if the ciphertext corresponding to the first character is found in the ciphertext database, obtaining the ciphertext corresponding to the first character;
if the ciphertext corresponding to the first character cannot be found in the ciphertext database, an encryption algorithm is adopted, a key corresponding to the first field name is used as a key, and the first character is encrypted, so that the ciphertext corresponding to the encrypted first character is obtained.
8. The fuzzy search apparatus of claim 6, wherein the first combining module is specifically configured to:
and encrypting, splicing and combining ciphertexts corresponding to all the first characters in sequence by adopting preset characters to obtain a first cipher text string corresponding to the plaintext information to be stored.
9. Computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor realizes the steps of the fuzzy search method according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the fuzzy search method according to any one of claims 1 to 5.
CN202010229002.3A 2020-03-27 2020-03-27 Fuzzy search method and device, computer equipment and storage medium Pending CN111475543A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010229002.3A CN111475543A (en) 2020-03-27 2020-03-27 Fuzzy search method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010229002.3A CN111475543A (en) 2020-03-27 2020-03-27 Fuzzy search method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111475543A true CN111475543A (en) 2020-07-31

Family

ID=71749321

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010229002.3A Pending CN111475543A (en) 2020-03-27 2020-03-27 Fuzzy search method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111475543A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112199420A (en) * 2020-10-16 2021-01-08 成都房联云码科技有限公司 House property privacy field information fuzzy search method
CN112311529A (en) * 2020-10-27 2021-02-02 银清科技有限公司 Data encryption method, data decryption method and data processing method of database
CN113221173A (en) * 2021-05-25 2021-08-06 江苏保旺达软件技术有限公司 Ciphertext processing method, device, equipment and storage medium
CN113806766A (en) * 2021-08-12 2021-12-17 招银云创信息技术有限公司 Data encryption method and device, computer equipment and storage medium
CN115563634A (en) * 2022-09-29 2023-01-03 北京海泰方圆科技股份有限公司 Retrieval method, device, equipment and medium
CN116701493A (en) * 2023-08-07 2023-09-05 中电信量子科技有限公司 Database operation method supporting fuzzy query and user side

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112199420A (en) * 2020-10-16 2021-01-08 成都房联云码科技有限公司 House property privacy field information fuzzy search method
CN112311529A (en) * 2020-10-27 2021-02-02 银清科技有限公司 Data encryption method, data decryption method and data processing method of database
CN113221173A (en) * 2021-05-25 2021-08-06 江苏保旺达软件技术有限公司 Ciphertext processing method, device, equipment and storage medium
CN113806766A (en) * 2021-08-12 2021-12-17 招银云创信息技术有限公司 Data encryption method and device, computer equipment and storage medium
CN115563634A (en) * 2022-09-29 2023-01-03 北京海泰方圆科技股份有限公司 Retrieval method, device, equipment and medium
CN115563634B (en) * 2022-09-29 2023-08-15 北京海泰方圆科技股份有限公司 Retrieval method, device, equipment and medium
CN116701493A (en) * 2023-08-07 2023-09-05 中电信量子科技有限公司 Database operation method supporting fuzzy query and user side
CN116701493B (en) * 2023-08-07 2023-10-31 中电信量子科技有限公司 Database operation method supporting fuzzy query and user side

Similar Documents

Publication Publication Date Title
CN111475543A (en) Fuzzy search method and device, computer equipment and storage medium
CN111191286B (en) HyperLegger Fabric block chain private data storage and access system and method thereof
US10284372B2 (en) Method and system for secure management of computer applications
CN111475824B (en) Data access method, device, equipment and storage medium
CN106997439B (en) TrustZone-based data encryption and decryption method and device and terminal equipment
CN106972927B (en) Encryption method and system for different security levels
CN106599723B (en) File encryption method and device and file decryption method and device
CN107786331B (en) Data processing method, device, system and computer readable storage medium
CN110826031B (en) Encryption method, device, computer equipment and storage medium
CN106911712B (en) Encryption method and system applied to distributed system
CN110391895B (en) Data preprocessing method, ciphertext data acquisition method, device and electronic equipment
US20230027142A1 (en) Method and apparatus for encrypting and decrypting and reading and writing messages, computer device, and storage medium
CN112469036A (en) Message encryption and decryption method and device, mobile terminal and storage medium
US10929402B1 (en) Secure join protocol in encrypted databases
CN110795747A (en) Data encryption storage method, device, equipment and readable storage medium
CN112131564A (en) Encrypted data communication method, apparatus, device, and medium
KR102421567B1 (en) Internet access management service server capable of providing internet access management service based on terminal grouping and operating method thereof
CN105825142A (en) Method and device for encrypting and decrypting documents in mobile terminal
US11695740B2 (en) Anonymization method and apparatus, device, and storage medium
CN114969768A (en) Data processing method and device and storage medium
CN116910712A (en) Code protection method, system, electronic equipment and storage medium
CN110990848A (en) Sensitive word encryption method and device based on hive data warehouse and storage medium
CN115603907A (en) Method, device, equipment and storage medium for encrypting storage data
CN115333753A (en) Internet protocol address generation method and device, storage medium and electronic equipment
US20230169186A1 (en) Method to secure computer code

Legal Events

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