Ciphertext data matching method based on csv file
Through the ciphertext data matching method based on CSV files, the mapping problem between plaintext user information and ciphertext user information is solved, and efficient data matching and security protection are achieved, which is suitable for enterprise-level network data security.
Patent Information
- Application Number
- CN202311009687.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-10
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-08-10
AI Technical Summary
After changing the third-party account, problems arise with the user's third-party data, requiring mapping of plaintext user information with ciphertext user information. Existing technologies cannot effectively solve the decryption and matching issues with SHA256-encrypted user information.
A ciphertext data matching method based on CSV files is adopted. By encrypting the plaintext user information and parsing and associating it with the three-party data files, a mapping relationship is generated, and finally the processed three-party data is exported.
It reduces the impact on system performance, improves the efficiency and accuracy of data matching, adapts to data sets of different sizes, and meets the needs of enterprise-level network data security.
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of data processing, and particularly relates to a ciphertext data matching method based on a csv file. BACKGROUND
[0002] After discovering that a three-party account is replaced in a production environment, three-party data of a user is problematic, and the three-party data of the user needs to be reprocessed. Since original user data of a name, an ID number and a mobile phone number are encrypted by SHA256, and there is no way to decrypt, user information in plaintext and user information after encryption need to be mapped to obtain three-party data of each user and perform processing. File formats are all csv formats. Problems to be solved are as follows:
[0003] 1. Current files: plaintext user information files, ciphertext user information and three-party data files;
[0004] Target files: plaintext user information and three-party data files;
[0005] 2. Encrypting the plaintext user information files to obtain encrypted user information files;
[0006] 3. Matching the encrypted user information files and original encrypted user information and three-party data files to obtain a mapping relationship;
[0007] 4. Processing the plaintext user information and three-party data files according to the mapping relationship. SUMMARY
[0008] Embodiments of the application provide a ciphertext data matching method based on a csv file, aiming to reduce the influence on system performance, and the processing of the entire process also produces a good adaptive effect on different data matching in the future.
[0009] In a first aspect, embodiments of the application provide a ciphertext data matching method based on a csv file, and specifically include the following steps:
[0010] Step one: reading plaintext files of user information, and encrypting a name, an ID number and a mobile phone number through a sha256 method in EncryptionUtil, and storing original plaintext user information and encrypted ciphertext user information in a Map;
[0011] Step two: analyzing and processing contents of the ciphertext user information and three-party data files in another Map;
[0012] Step three: processing data of the two Maps in the above steps one and two respectively, and splicing to generate sql that can be inserted into a table;
[0013] Step four: creating a user information table and a three-party data table by means of a database,
[0014] The user information table is used to store the plaintext three elements and the encrypted three elements of the user;
[0015] The three-party data table is used to store the encrypted three elements and the three-party data;
[0016] Step five: according to the generated sql, the data of the two files are one-to-one mapped and inserted into the corresponding tables respectively;
[0017] Step six: an association query is established to associate the two tables by using the encrypted user name, ID number and mobile phone number as the association fields, obtain a mapping relationship, and generate a temporary table,
[0018] Step seven: by means of the DbVisualizer database management tool, the plaintext user three elements and the three-party data are exported as a csv file, the three-party data is processed according to the agreed manner, and the final result is obtained.
[0019] Preferably, the ciphertext data matching method based on the csv file according to claim 1, the specific steps are characterized in that: in step three, the plaintext and ciphertext user information is taken as a table, the table header is TM_ID_NAME_CELL, and the ciphertext user information and the three-party data are taken as another table, the table header is TM_TD_VALUE.
[0020] Preferably, the table header of the user information table is TM_ID_NAME_CELL, and the table header of the three-party data table is TM_TD_VALUE.
[0021] Preferably, the data in the temporary table is the ciphertext user three elements, the plaintext user three elements and the corresponding three-party data of the user.
[0022] In the second aspect, the application further provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the method of the first aspect.
[0023] Compared with the prior art, the embodiment of the application has the following beneficial effects:
[0024] The whole process is based on the java development language, the database is DB2, and the high performance of the database association query is mainly used to process a large amount of data. Compared with the traditional matching through the java code, the influence of the system performance is reduced, and the whole process of processing also has a good adaptive effect on different data matching in the future. DETAILED DESCRIPTION
[0025] In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular architectures, technologies, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
[0026] It is to be understood that the terminology "includes", "comprises", "consists of", "consists essentially of" and like phrases as used in the specification and in the following claims denotes an open term that does not exclude additional, unrecited elements or steps. Thus, such terminology, when applied to a list of items shall be interpreted as including at least the recited items and not excluding additional, unrecited items.
[0027] It is also to be understood that the terminology "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0028] It is further to be understood that the term "or" as used herein refers to any or all possible combinations of one or more of the associated listed items and includes each of the possible combinations.
[0029] Reference throughout this specification to "one embodiment" or "an embodiment" or "a specific embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" or "in some embodiments" or "in other embodiments" or "in still other embodiments" in various places throughout this specification are not necessarily all referring to the same embodiment, unless otherwise specifically so stated. Furthermore, the term "comprising" or "comprises" or "including" or "includes" or "containing" or "contains" or "characterized by" or "characterized by" as used herein is used in the sense of "including, but not limited to," even if the term applies to only one of the enunciated features, structures, or characteristics.
[0030] The terms "including", "comprising", "having" and their conjugates mean "including but not limited to", unless otherwise expressly specified.
[0031] With the continuous development of information technology, network security has become an important field of concern for enterprises. Existing network attack methods are increasingly rampant, and encryption and decryption, data leakage and other problems are increasingly prominent. Therefore, it is an urgent task to protect the security of enterprise information assets.
[0032] The present application aims to improve the security and reliability of enterprise network data. The present application adopts a CSV file-based cryptography data matching method, which encrypts and decrypts the original data, compares and matches the data, extracts sensitive information, and encrypts the sensitive information, thereby protecting the security of enterprise network data.
[0033] The present application adopts a CSV file-based cryptography data matching method,
[0034] The original data is encrypted and decrypted to obtain encrypted data.
[0035] The encrypted data is compared and matched to extract sensitive information from the matching result.
[0036] The sensitive information is encrypted to obtain encrypted sensitive information.
[0037] The encrypted sensitive information is compared and matched to obtain a more accurate matching result.
[0038] The data matching scheme based on cryptography technology can improve the security and reliability of data, can handle large data sets, can meet the needs of enterprise-level network data security, has scalability, can adapt to different sizes of data sets, and can be optimized for performance.
[0039] The technical solution of this project can be applied to the field of enterprise network data security, for example:
[0040] The network data is encrypted and decrypted to ensure the security of the data.
[0041] Sensitive data is extracted, encrypted and decrypted to improve the reliability of the data.
[0042] The matching result is encrypted and decrypted to ensure the security of sensitive data.
[0043] The public key and private key technology in cryptography is used to realize the comparison and matching of encrypted data, extract sensitive information from the matching result, and encrypt the sensitive information, thereby improving the security and reliability of the data.
[0044] In one possible implementation, steps one and two are given specific example processes:
[0045] The example environment is a Java program that encrypts the contents of a file. The program first defines a HashMap object called paramHap to store the encrypted data. Then a variable called count is defined to record the number of lines that have been processed.
[0046] Next, the program uses a try...catch block to create a BufferedReader object to read the contents of the file. In the loop, each time a line of data is read, it is converted to a string array, and the required data (i.e. ID number, name, cell value) is extracted and encrypted. Finally, the encrypted data is added to the paramHap object.
[0047] The encryption process uses the SHA256 algorithm, first using replacement as a replacement character, then using shr256 for encryption. Finally, the encrypted data is written to the csw file.
[0048] The program also uses the mriteri.write() method to generate a CSV file (i.e., Constructional Sword) that records the encrypted path and operations.
[0049] The next code defines a FileWriter object named mriteri to write to the CSW file. Finally, the program uses the System.out.println() method to print some log information for debugging and observing the program's running state. The program uses the SHA256 algorithm to encrypt the contents of the file and writes it to the CSW file. The program uses the HashMap and BufferedReader / Writer objects for file reading and writing operations.
[0050] A Java function is used to encrypt the input string "input" using the SHA-256 algorithm and store the result in a variable named "encodedstr".
[0051] Specifically, this function takes two parameters: the string to be encrypted "input" and the type of encryption "type" as a string. The encryption type "type" can be any string, but in this example, "SHA-256" is used as the default value.
[0052] Inside the function, a class called "MessageDigest" is first called and its instance is used to create an object named "messageDigest". Then, the "update" method of the "messageDigest" object is used to update the hash value of the input string "input". In this process, a parameter called "charsetName" is used to specify which character set to use to encode the input string. In this example, UTF-8 encoding is used.
[0053] Finally, a method called "byte2Hex" is used to convert the hash value of the "messageDigest" object into a hexadecimal string and store it in the "encodedstr" variable. If any exceptions occur, they will be caught in two different exceptions and the corresponding error messages will be output.
[0054] Finally, the function returns the value of the "encodedstr" variable to return the encryption result to the caller.
[0055] A given ResponseResult object result is processed and the processing result is stored in the database table TM_TD_VALUE.
[0056] Specifically, this code functions as follows:
[0057] A new ResponseResult object result is created;
[0058] The columns that need to be stored in the database table are extracted from the list object and converted into a string array columnsArray;
[0059] A new RiskItem object riskItems is created and the value of each element extracted from the list object is stored in riskItems;
[0060] A new ResultDesc object resultDesc is created and the riskItems object is set as the riskItems attribute of the resultDesc object;
[0061] The result object is set to success and the processing result is set to the resultDesc object;
[0062] A NameValvepair object nameValvePair1 is defined and set to the value of the name: column;
[0063] A NameValvepair object nameValvePair2 is defined and set to the value of the idNo: column;
[0064] A NameValvepair object nameValvePair3 is defined and set to the value of the cell: column;
[0065] The gensqLInsert method is called to store the NameValvepair objects nameValvePair1, nameValvePair2, and nameValvePair3 into the TM_TD_VALUE database table and the result is stored as a Result object result;
[0066] The processing result is output.
[0067] The specific implementation in step three is Java code for generating an INSERT INTO statement. The implementation functions as follows:
[0068] 1. A static method named gensqLnsert is defined, which accepts two parameters: one is the table name to be inserted (string type), and the other is a dictionary containing the record to be inserted (Map<String, Object> type).
[0069] 2. If the dictionary to be inserted is empty, return null.
[0070] 3. Define a StringBuilder object named sbField to store the values of the record to be inserted.
[0071] 4. Define a StringBuilder object named sbValue to store the values of the record to be inserted.
[0072] 5. Traverse the entrySet method of dataMap, and for each Map.Entry, insert its value into sbField. Specifically, first define a string variable named mapKey that stores the name of the field to be inserted into the record; then define a string variable named mapValve that stores the value to be inserted into the record.
[0073] 6. For each Map.Entry, convert mapKey to uppercase and concatenate it to the value of sbField.
[0074] 7. Finally, convert sbField and sbValue to strings, concatenate them together, remove the extra "," and "'", and return the result.
[0075] In simple terms, the data in the input map is inserted into the specified table, and for each record, the corresponding value is inserted into the record value field.
[0076] Steps four to seven are the same as the invention content and will not be repeated.
[0077] The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0078] It should be noted that the information interaction, execution process, etc. between the above devices / units, since based on the same concept as the method embodiments of the present application, the specific functions and technical effects brought about can be referred to the method embodiments part, and will not be repeated here.
[0079] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed 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 complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction, and do not limit the protection scope of the application. The specific working process of the unit and module in the system can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0080] The embodiment of the application further provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the steps in each method embodiment.
[0081] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.
[0082] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the application.
[0083] The above-described embodiments are only used to illustrate the technical solutions of the application, rather than limit them; although the application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in the protection scope of the application.
Claims
1. A ciphertext data matching method based on CSV files, characterized in that: The specific steps include: Step 1: Read the plaintext file of user information and encrypt the name, ID number and mobile phone number using the sha256 method in EncryptionUtil. The original plaintext user information and the encrypted ciphertext user information are stored in a Map; Step 2: Parse the encrypted user information and the contents of the third-party data file and place them in another Map; Step 3: Process the data of the two maps in steps 1 and 2 above respectively, and splice them to generate SQL that can be inserted into the table; Step 4: Create a new user information table and a third-party data table with the help of the database. The user information table is used to store the user's three plaintext elements and three encrypted elements; The three-party data table is used to store the encrypted three elements and three-party data; Step 5: According to the generated SQL, map the data of the two files one by one and insert them into the corresponding tables respectively; Step 6: Create an associated query, use the encrypted user name, ID number and mobile phone number as the associated fields to associate the two tables, obtain a mapping relationship, and generate a temporary table. Step 7: Use the DbVisualizer database management tool to export the plaintext user three elements and three-party data into a CSV file, and process the three-party data according to the agreed method to obtain the final result.
2. The ciphertext data matching method based on CSV files according to claim 1, wherein the specific steps are characterized by: The entire traversal process uses name, ID number and mobile phone number as key fields.
3. The ciphertext data matching method based on CSV files according to claim 1, wherein the specific steps are as follows: In step 3, the plaintext and encrypted user information is used as a table with the header TM_ID_NAME_CELL, and the ciphertext user information and third-party data is used as another table with the header TM_TD_VALUE.
4. The ciphertext data matching method based on CSV files according to claim 1, wherein the specific steps are characterized by: The header of the user information table is TM_ID_NAME_CELL; the header of the third-party data table is TM_TD_VALUE.
5. The ciphertext data matching method based on CSV files according to claim 1, wherein the specific steps are characterized by: The data in the temporary table includes the three elements of the encrypted user, the three elements of the plain text user, and the three-party data corresponding to the user.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Attribute-based secure communication method and system supporting ciphertext mode matching
CN111556048A
Data query method and device, electronic equipment and computer readable medium
CN116383867A