Secure excel file transfer method and system
Through encryption and decryption operations, the consistency of the equivalent record of the excel file and the encrypted record is verified, and the content information of the decrypted file is matched with the display field of the business module, which solves the problem of data tampering during the sending or transfer process of the excel file. The secure transfer of files and the authenticity of data are achieved.
Patent Information
- Application Number
- CN202410923206.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-10-15
AI Technical Summary
During the sending or transfer process of excel files, the file data is easily tampered with, leading to data fraud.
By generating encrypted information, including excel encrypted files, delimited characters and encrypted records, perform encryption and decryption operations, verify the consistency of equivalent records and encrypted records, and match the content information of the decrypted file with the display fields of the business module to ensure Secure transfer of files.
It effectively avoids the tampering of file data, ensures the authenticity and integrity of the data, and prevents forgery of form data.
Smart Images

Figure CN118779900A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of encryption technology, and in particular to a method and system for securely transferring an Excel file. Background Art
[0002] In daily work, it is often necessary to send or transfer Excel files. The data in the files depends on business personnel during the sending or transfer process, and the file data may be tampered with, resulting in data falsification. Summary of the invention
[0003] In view of the problems raised by the background technology, the purpose of the present invention is to propose a method and system for securely transferring Excel files, which solves the problem of tampering with file data during the sending or transfer process, resulting in data falsification.
[0004] To achieve this object, the present invention adopts the following technical solutions:
[0005] A method for securely transferring an Excel file comprises the following steps:
[0006] S1. Obtain encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, separator characters and encrypted records, and the encrypted records are stored in the database;
[0007] S2, sending the encrypted information to the decryption interface, separating and decrypting the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface;
[0008] S3, verifying the equivalent record to determine whether the equivalent record is consistent with the encrypted record and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed;
[0009] S4. Parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
[0010] Preferably, in S1, the encryption interface implements the encryption process of the excel initial file as follows:
[0011] S11, set the key in the configuration file;
[0012] S12, define a separator character, the separator character is used to separate the encrypted record and the excel initial file;
[0013] S13, generating the encrypted record through the encryption interface; converting the excel initial file, the separator character and the encrypted record into byte type respectively, and splicing them to form an integrated byte type;
[0014] S14. According to the key and the integrated byte, the encryption interface calls an encryption method to perform encryption to form encrypted information.
[0015] Preferably, the configuration file adopts the bootstrap.yml configuration file, and the encryption method adopts the AES encryption method.
[0016] Preferably, the encrypted record includes an identification record ID, an Excel file name, encryption time and remarks information, and the identification record ID is uniquely stored in the database.
[0017] Preferably, in S2, the decryption interface implements the decryption process of the excel encrypted file as follows:
[0018] S21, receiving the encrypted information through the decryption interface;
[0019] S22, restoring the encrypted information to a byte type, and according to the key, the decryption interface calls a decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file;
[0020] S23, using the separation character to separate the excel decrypted file and the equivalent record.
[0021] Preferably, in S4, the process of completing the secure transfer of files is as follows:
[0022] S41, parsing the content information of the excel decrypted file through Apache POI, and extracting the header fields and table data of the excel decrypted file;
[0023] S42, storing the header fields and the table data in a database;
[0024] S43, selecting a business module, obtaining display fields required by the business module, and matching the display fields with the header fields one by one;
[0025] S44. When the matching is completed, the table data corresponding to the header field in the database is extracted to complete the safe transfer of the Excel file.
[0026] Accordingly, the present invention provides a system for secure transfer of Excel files, comprising an acquisition module, a decryption module, a verification module, an information security transfer module and the above-mentioned method for secure transfer of Excel files;
[0027] The acquisition module is used to acquire the encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, the separator character and the encrypted record, and the encrypted record is stored in the database;
[0028] The decryption module is used to send the encrypted information to the decryption interface, separate and decrypt the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface;
[0029] The verification module is used to verify the equivalent record, determine whether the equivalent record is consistent with the encrypted record, and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed;
[0030] The information security transfer module is used to parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
[0031] Preferably, the acquisition module includes a configuration module, a separation module, a splicing module and an encryption module;
[0032] The configuration module is used to set the key in the configuration file, and the configuration file adopts the bootstrap.yml configuration file;
[0033] The separation module is used to define a separation character, and the separation character is used to separate the encrypted record and the excel initial file;
[0034] The splicing module is used to generate the encrypted record through the encryption interface; convert the excel initial file, the separator character and the encrypted record into byte type respectively, and splice them to form an integrated byte type;
[0035] The encryption module is used to encrypt according to the key and the integrated byte, and the encryption interface calls the encryption method to form encrypted information; wherein the encryption method adopts the AES encryption method.
[0036] Preferably, the decryption module includes a receiving module, a decryption submodule and a segmentation module;
[0037] The receiving module is used to receive the encrypted information through the decryption interface;
[0038] The decryption submodule is used to restore the encrypted information into a byte type. According to the key, the decryption interface calls the decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file;
[0039] The segmentation module is used to separate the excel decrypted file and the equivalent record using the separation character.
[0040] Preferably, the information security transfer module includes an information parsing module, a data storage module, a matching field module and a security transfer submodule;
[0041] The information parsing module is used to parse the content information of the excel decrypted file through Apache POI, and extract the header fields and table data of the excel decrypted file;
[0042] The data storage module is used to store the header fields and the table data in a database;
[0043] The matching field module is used to select a business module, obtain the display field required by the business module, and match the display field with the header field one by one;
[0044] The secure transfer submodule is used to extract the table data corresponding to the header field in the database when the matching is completed, and complete the secure transfer of the Excel file.
[0045] Compared with the prior art, one of the above technical solutions has the following beneficial effects:
[0046] The present invention encrypts the excel initial file to generate the excel encrypted file, decrypts the file to generate the excel decrypted file, verifies the equivalent record, determines the validity of the excel decrypted file, and matches the header field of the content information with the display field of the business module to complete the secure transfer of the file. Business personnel cannot change the table data of the content information, avoid the phenomenon of forged table data, and ensure the authenticity of the data source. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flow chart of an embodiment of the present invention;
[0048] Figure 2 It is a schematic flow diagram of the variation process of the present invention. DETAILED DESCRIPTION
[0049] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0050] like Figures 1-2 As shown, a method for securely transferring an Excel file comprises the following steps:
[0051] S1. Obtain encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, separator characters and encrypted records, and the encrypted records are stored in the database;
[0052] S2, sending the encrypted information to the decryption interface, separating and decrypting the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface;
[0053] S3, verifying the equivalent record to determine whether the equivalent record is consistent with the encrypted record and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed;
[0054] S4. Parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
[0055] In the present invention, in addition to encrypting the excel initial file, the encryption information also includes the encryption record and the separator character. The encryption information is downloaded and sent to the decryption interface for decryption to generate the equivalent record and the excel decryption file. When the equivalent record meets the verification condition, the validity of the excel decryption file is indicated. In other words, by generating the encryption record and the equivalent record, the encryption and decryption process carries information other than the file content, which can be used to read the encryption record or the equivalent record to detect whether there is an encryption operation, so as to determine whether the encryption and decryption process complies with the "excel initial file-excel encryption file-excel decryption file" process performed by the same excel file, so as to avoid the excel encryption file provided by other external interfaces, which causes the data tampering of the file content and ensure the authenticity of the data source.
[0056] In addition, by parsing the content information of the excel decrypted file, the business personnel match the header field of the content information with the display field of the business module. The front end only presents the header field and the display field, and the import of the table data of the content information is matched at the back end. Business personnel cannot change the table data of the content information, avoiding the phenomenon of forged table data.
[0057] Preferably, in S1, the encryption interface implements the encryption process of the excel initial file as follows:
[0058] S11, set the key in the configuration file;
[0059] S12, define a separator character, the separator character is used to separate the encrypted record and the excel initial file;
[0060] S13. Generate the encrypted record through the encryption interface, and convert the encrypted record into a json file; convert the excel initial file, the separator character and the encrypted record into byte type respectively, and splice them to form an integrated byte. Specifically, the excel initial file is converted into a byte array byte[]: file1Content; the separator character is defined as "jmwjsparator" and converted into a byte array byte[]: separator; the encrypted record is converted into a byte array byte[]: file2Content. Splicing the three bytes[] to form an integrated byte array byte[] means encrypting the excel initial file and the encrypted record into one file, wherein the separator character is used to separate the excel encrypted file and the encrypted record during decryption.
[0061] S14. According to the key and the integrated byte, the encryption interface calls the encryption method to encrypt to form encrypted information, and the encrypted information is converted into a jmwj file.
[0062] Preferably, the configuration file adopts the bootstrap.yml configuration file, and the encryption method adopts the AES encryption method.
[0063] Specifically, the configuration file adopts the bootstrap.yml configuration file, which is a special configuration file in Spring Cloud Config for obtaining external configuration, and has a higher loading priority than other configuration files (such as application.yml or application.properties, etc.).
[0064] Specifically, in a Java program, the javax.crypto.Cipher class implements encryption and decryption algorithms. This Cipher class provides encryption and decryption functions and can be used to protect data security. Therefore, the present invention implements the AES encryption method through the Cipher class.
[0065] Preferably, the encrypted record includes an identification record ID, an Excel file name, encryption time and remarks information, and the identification record ID is uniquely stored in the database.
[0066] Specifically, since the identification record ID is uniquely stored in the database, the decryption verification can be performed through the identification record ID. The excel file name, the encryption time and the remarks information facilitate verification of the encrypted record.
[0067] Preferably, in S2, the decryption interface implements the decryption process of the excel encrypted file as follows:
[0068] S21, receiving the encrypted information through the decryption interface;
[0069] S22, restoring the encrypted information to a byte type, and according to the key, the decryption interface calls a decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file;
[0070] S23, using the separation character to separate the excel decrypted file and the equivalent record.
[0071] Generally, the encrypted record generates an equivalent record, and the encrypted record is consistent with the equivalent record; the Excel encrypted file generates an Excel decrypted file, and the Excel decrypted file is consistent with the Excel initial file; the stability of the encryption and decryption process is maintained.
[0072] Preferably, in S4, the process of completing the secure transfer of files is as follows:
[0073] S41, parsing the content information of the excel decrypted file through Apache POI, and extracting the header fields and table data of the excel decrypted file;
[0074] S42, storing the header fields and the table data in a database;
[0075] S43, selecting a business module, obtaining display fields required by the business module, and matching the display fields with the header fields one by one;
[0076] S44. When the matching is completed, the table data corresponding to the header field in the database is extracted to complete the safe transfer of the Excel file.
[0077] It should be noted that Apache POI is a free, open source, cross-platform Java API written in Java. Apache POI provides an API for Java programs to read and write Excel files. Therefore, the header field key and table data value of the Excel decrypted file can be read through Apache POI.
[0078] In one embodiment provided by the present invention, the header field is key "order number", and the table data value is ["1111", "2222", "3333", "4444"], wherein the table data value in the Excel decryption file is the value of the column where the header field key is located.
[0079] Store the header field key and table data value in the database, including: excelId, key and value. Return the header field key and record excelId to the front end.
[0080] The front end selects the business module modelType to be imported, such as the pound bill module pound, and obtains the display fields required for the pound bill module: pound bill number poundNo, weight poundTotalWeight, tare weight tareWeigh, gross weight grossWeight and net weight netWeight. The header field keys returned by the excel decryption file are: bill number, total weight, tare weight, gross weight and tare weight. The business personnel select and match the display fields with the header fields, such as matching the bill number poundNo, matching the gross weight for poundTotalWeight, matching the tare weight for tareWeigh, matching the gross weight for grossWeight, and matching the tare weight for netWeight.
[0081] After selecting the match, submit the selection: {modelType: "pound", match: {"poundNo": "order number", "poundTotalWeight": "total weight", "tareWeight": "tare weight", "grossWeight": "gross weight", "netWeight": "tare weight"}, excelId: "xxxx"} to the backend to import the data interface.
[0082] The back-end import data interface obtains the required display field object according to the scale order module, and obtains the header field key and table data value according to excelId. Obtain the table data length, that is, the length of the array converted from the value into a string array, and assemble it in a loop according to the length.
[0083] According to the selection parameter poundNo, the table data under the "order number" header will be read; according to the selection parameter poundTotalWeight, the table data under the "tare weight" header will be read; according to the selection parameter grossWeight, the table data under the "gross weight" header will be read; according to the selection parameter netWeight, the table data under the "tare weight" header will be read; the data list that constitutes the weighing order module is inserted into the weighing order module.
[0084] For example, the content information of the excel decrypted file:
[0085] Order Number gross weight Tare weight Gross Weight Tare weight 1111 10 1 2 9 2222 20 1 2 19 3333 30 1 2 29 4444 40 1 2 39
[0086] According to the selected business module
[0087] {modelType:"pound","match":{"poundNo":"order number","poundTotalWeight":"total weight","tareWeight":"tare weight","grossWeight":"gross weight","netWeight":"tare weight"},excelId:"xxxx"}
[0088] The data list of the successfully assembled scale module is as follows:
[0089] [{"poundNo":"1111","poundTotalWeight":"10","tareWeight":"1","grossWeight":"2","netWeight":"9"},
[0090] {"poundNo":"2222","poundTotalWeight":"20","tareWeight":"1","grossWeight":"2","netWeight":"19"},
[0091] {"poundNo":"3333","poundTotalWeight":"30","tareWeight":"1","grossWeight":"2","netWeight":"29"},
[0092] {"poundNo":"4444","poundTotalWeight":"30","tareWeight":"1","grossWeight":"2","netWeight":"39"}]
[0093] The above completes the safe transfer of Excel files.
[0094] It should be noted that the present invention also provides a system for secure transfer of Excel files, including an acquisition module, a decryption module, a verification module, an information security transfer module and the above-mentioned method for secure transfer of Excel files;
[0095] The acquisition module is used to acquire the encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, the separator character and the encrypted record, and the encrypted record is stored in the database;
[0096] The decryption module is used to send the encrypted information to the decryption interface, separate and decrypt the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface;
[0097] The verification module is used to verify the equivalent record, determine whether the equivalent record is consistent with the encrypted record, and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed;
[0098] The information security transfer module is used to parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
[0099] Preferably, the acquisition module includes a configuration module, a separation module, a splicing module and an encryption module;
[0100] The configuration module is used to set the key in the configuration file, and the configuration file adopts the bootstrap.yml configuration file;
[0101] The separation module is used to define a separation character, and the separation character is used to separate the encrypted record and the excel initial file;
[0102] The splicing module is used to generate the encrypted record through the encryption interface; convert the excel initial file, the separator character and the encrypted record into byte type respectively, and splice them to form an integrated byte type;
[0103] The encryption module is used to encrypt according to the key and the integrated byte, and the encryption interface calls the encryption method to form encrypted information; wherein the encryption method adopts the AES encryption method.
[0104] Preferably, the decryption module includes a receiving module, a decryption submodule and a segmentation module;
[0105] The receiving module is used to receive the encrypted information through the decryption interface;
[0106] The decryption submodule is used to restore the encrypted information into a byte type. According to the key, the decryption interface calls the decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file;
[0107] The segmentation module is used to separate the excel decrypted file and the equivalent record using the separation character.
[0108] Preferably, the information security transfer module includes an information parsing module, a data storage module, a matching field module and a security transfer submodule;
[0109] The information parsing module is used to parse the content information of the excel decrypted file through Apache POI, and extract the header fields and table data of the excel decrypted file;
[0110] The data storage module is used to store the header fields and the table data in a database;
[0111] The matching field module is used to select a business module, obtain the display field required by the business module, and match the display field with the header field one by one;
[0112] The secure transfer submodule is used to extract the table data corresponding to the header field in the database when the matching is completed, and complete the secure transfer of the Excel file.
[0113] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0114] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for securely transferring an Excel file, characterized in that: The following steps are involved: S1. Obtain encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, separator characters and encrypted records, and the encrypted records are stored in the database; S2, sending the encrypted information to the decryption interface, separating and decrypting the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface; S3, verifying the equivalent record to determine whether the equivalent record is consistent with the encrypted record and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed; S4. Parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
2. A method for securely transferring an Excel file according to claim 1, characterized in that: In S1, the encryption interface implements the encryption process of the excel initial file as follows: S11, set the key in the configuration file; S12, define a separator character, the separator character is used to separate the encrypted record and the excel initial file; S13, generating the encrypted record through the encryption interface; converting the excel initial file, the separator character and the encrypted record into byte type respectively, and splicing them to form an integrated byte type; S14. According to the key and the integrated byte, the encryption interface calls an encryption method to perform encryption to form encrypted information.
3. A method for securely transferring an Excel file according to claim 2, characterized in that: The configuration file adopts the bootstrap.yml configuration file, and the encryption method adopts the AES encryption method.
4. The method for securely transferring an Excel file according to claim 2, characterized in that: The encrypted record includes an identification record ID, an Excel file name, encryption time and remarks information, and the identification record ID is uniquely stored in the database.
5. The method for securely transferring an Excel file according to claim 2, characterized in that: In S2, the decryption interface implements the decryption process of the excel encrypted file as follows: S21, receiving the encrypted information through the decryption interface; S22, restoring the encrypted information to a byte type, and according to the key, the decryption interface calls a decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file; S23, using the separation character to separate the excel decrypted file and the equivalent record.
6. The method for securely transferring an Excel file according to claim 1, characterized in that: In S4, the process of completing the secure transfer of the file is as follows: S41, parsing the content information of the excel decrypted file through Apache POI, and extracting the header fields and table data of the excel decrypted file; S42, storing the header fields and the table data in a database; S43, selecting a business module, obtaining display fields required by the business module, and matching the display fields with the header fields one by one; S44. When the matching is completed, the table data corresponding to the header field in the database is extracted to complete the safe transfer of the Excel file.
7. A system for securely transferring Excel files, using a method for securely transferring Excel files as claimed in any one of claims 1 to 6, characterized in that: It includes an acquisition module, a decryption module, a verification module and an information security transfer module; The acquisition module is used to acquire the encryption information of the excel initial file generated by the encryption interface; wherein the encryption information includes the excel encrypted file, the separator character and the encrypted record, and the encrypted record is stored in the database; The decryption module is used to send the encrypted information to the decryption interface, separate and decrypt the encrypted information; wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file through the decryption interface; The verification module is used to verify the equivalent record, determine whether the equivalent record is consistent with the encrypted record, and whether the encrypted record is stored in the database. If both are yes, it is determined that the Excel decrypted file generated by the Excel encrypted file through the decryption interface is consistent with the Excel initial file, and the decryption of the encrypted information is completed; The information security transfer module is used to parse the content information of the excel decrypted file, match the header field of the content information with the display field of the business module, and complete the secure transfer of the file.
8. The system for securely transferring Excel files according to claim 7, characterized in that: The acquisition module includes a configuration module, a separation module, a splicing module and an encryption module; The configuration module is used to set the key in the configuration file, and the configuration file adopts the bootstrap.yml configuration file; The separation module is used to define a separation character, and the separation character is used to separate the encrypted record and the excel initial file; The splicing module is used to generate the encrypted record through the encryption interface; convert the excel initial file, the separator character and the encrypted record into byte type respectively, and splice them to form an integrated byte type; The encryption module is used to encrypt according to the key and the integrated byte, and the encryption interface calls the encryption method to form encrypted information; wherein the encryption method adopts the AES encryption method.
9. The system for securely transferring Excel files according to claim 7, characterized in that: The decryption module includes a receiving module, a decryption submodule and a segmentation module; The receiving module is used to receive the encrypted information through the decryption interface; The decryption submodule is used to restore the encrypted information into a byte type. According to the key, the decryption interface calls the decryption method to decrypt, wherein the encrypted record generates an equivalent record, and the Excel encrypted file generates an Excel decrypted file; The segmentation module is used to separate the excel decrypted file and the equivalent record using the separation character.
10. The system for securely transferring Excel files according to claim 7, characterized in that: The information security transfer module includes an information parsing module, a data storage module, a matching field module and a security transfer submodule; The information parsing module is used to parse the content information of the excel decrypted file through Apache POI, and extract the header fields and table data of the excel decrypted file; The data storage module is used to store the header fields and the table data in a database; The matching field module is used to select a business module, obtain the display field required by the business module, and match the display field with the header field one by one; The secure transfer submodule is used to extract the table data corresponding to the header field in the database when the matching is completed, and complete the secure transfer of the Excel file.
