Data security method and device, computer device and storage medium

By copying the original data to a buffer and generating encrypted output data using obfuscation values ​​and index numbers in embedded software development, the problem of easily leaked sensitive data in binary files is solved, and secure encryption and restoration of data are achieved.

CN115481411BActive Publication Date: 2026-01-09SHINRY TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210877834.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-25
Publication Date
2026-01-09
Estimated Expiration
2042-07-25

AI Technical Summary

Technical Problem

In embedded software development, sensitive plaintext data in binary files can be easily leaked by third-party tools, leading to information leakage.

Method used

By acquiring the original data and copying it to the cache area, the cached data is input into the output area according to a specific index number using the obfuscation value and data index number, generating encrypted output data, and supporting the restoration of the output data.

Benefits of technology

It improves information security by converting sensitive plaintext data into ciphertext data to prevent leakage and supports data restoration and recovery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115481411B_ABST
    Figure CN115481411B_ABST
Patent Text Reader

Abstract

The application discloses a data security method and device, computer equipment and a storage medium. The data security method comprises the following steps: obtaining original data; copying the original data to a cache area to obtain cache data; taking the first data of the cache data as the first data of output data; determining a data index number according to the first data of the cache data and a confusion value; inputting the cache data into an output area according to the data index number to obtain the output data. The data security method can improve information security and change sensitive plaintext data in a binary file into ciphertext data for protection.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of information security, and in particular to a data security method and device, computer equipment and a storage medium. BACKGROUND

[0002] In the process of embedded software development, program files are often transferred in the form of binary files, and some sensitive plaintext data (such as software information, parameter information, key information, etc.) usually exist in these binary files. When a third party opens the binary file by using a binary tool, the sensitive plaintext data can be easily found, thereby causing information leakage. SUMMARY

[0003] Therefore, the embodiments of the present application provide a data security method and device, computer equipment and a storage medium to solve the problem that sensitive plaintext data in a binary file is easily leaked.

[0004] In a first aspect, the embodiments of the present application provide a data security method, comprising:

[0005] obtaining original data;

[0006] copying the original data to a cache area to obtain cache data;

[0007] taking the first data of the cache data as the first data of output data;

[0008] determining a data index number according to the first data of the cache data and a confusion value;

[0009] inputting the cache data to an output area according to the data index number to obtain the output data.

[0010] In any possible implementation of the above-mentioned aspect, the first data of the cache data is taken as an initial data index number.

[0011] an intermediate data index number is obtained according to the confusion value and the initial data index number, wherein after data is input from the cache data to the output area each time, the cache data is deleted, the array length of the cache area is reduced by one, and the intermediate data index number is determined after the array length of the cache area is changed each time, so as to determine the next data input to the output area according to the intermediate data index number.

[0012] In any possible implementation of the above-mentioned aspect, the confusion value and the initial data index number are subjected to XOR operation to obtain a first XOR value.

[0013] The first intermediate data index number is obtained by dividing the first XOR value by the length of the cache area and taking the remainder.

[0014] The second XOR value is obtained by performing XOR operation on the obfuscation value and the data corresponding to the first intermediate data index number.

[0015] The second intermediate data index number is obtained by dividing the second XOR value by the length of the cache area after the length change and taking the remainder, and the remaining intermediate data index numbers are obtained in the same way, so that the cache data is input to the output area according to the intermediate data index numbers, and the output data is obtained.

[0016] According to any possible implementation of the aspect as described above, an implementation is further provided, and the method further comprises:

[0017] The output data is copied to the cache area.

[0018] The data in the cache area is reversed to obtain the cache data.

[0019] Except for the last data in the cache data, the first data and the second data are sequentially taken out from the cache data, wherein the first data and the second data are adjacent.

[0020] The data index number of the first data is determined according to the second data and the obfuscation value, specifically comprising: x = (d[a+1]^SV)%(a+1), wherein x represents the data index number of the first data, d[a+1] represents the second data, ^ represents XOR calculation, SV represents the obfuscation value, % represents remainder calculation, a represents the label of the first data in the cache data, and a+1 represents the label of the second data in the cache data.

[0021] The first data is input to the output area according to the data index number of the first data, and finally, the last data in the cache data is input to the output area as the first data of the output data, and the data already existing in the output area is moved one position backward.

[0022] According to any possible implementation of the aspect as described above, an implementation is further provided, and the method further comprises:

[0023] The first data in the cache data is input to the output area according to the data index number of the first data.

[0024] input the second data in the cache data to the output area according to the data index number of the first data of the second round input;

[0025] determine the data index number of the first data of the second round input according to the second data of the second round input and the confusion value;

[0026] input the second data in the cache data to the output area according to the data index number of the first data of the second round input;

[0027] By analogy, except for the last data in the cache data, input the data in the corresponding position of the cache data to the output area according to the data index number of the first data of each round input, wherein, when inputting the data each time, the data in the position corresponding to the data index number of the first data of each round input and the data after the position are moved one position backward.

[0028] In a second aspect, the embodiments of the present application provide a data security device, comprising:

[0029] a first obtaining module, configured to obtain original data;

[0030] a second obtaining module, configured to copy the original data to a cache area to obtain cache data;

[0031] a first determining module, configured to take the first data of the cache data as the first data of output data;

[0032] a second determining module, configured to determine a data index number according to the first data of the cache data and a confusion value;

[0033] a third obtaining module, configured to input the cache data to an output area according to the data index number to obtain the output data.

[0034] Further, the second determining module is specifically configured to:

[0035] take the array position of the first data of the cache data as an initial data index number;

[0036] obtain an intermediate data index number according to the confusion value and the initial data index number, wherein, after inputting the data from the cache data to the output area each time, the cache data deletes the data inputted this time, and the array length of the cache area is reduced by one, the intermediate data index number is the index number determined after the array length of the cache area changes each time, so as to determine the data inputted to the output area next time according to the intermediate data index number.

[0037] Further, the second determining module is further specifically configured to:

[0038] XOR operation is performed on the obfuscation value and the data corresponding to the initial data index number, to obtain a first XOR value;

[0039] The first intermediate data index number is obtained by performing remainder operation on the first XOR value and the length of the cache area;

[0040] XOR operation is performed on the obfuscation value and the data corresponding to the first intermediate data index number, to obtain a second XOR value;

[0041] The second intermediate data index number is obtained by performing remainder operation on the second XOR value and the length of the cache area after the length change, and the remaining intermediate data index numbers are obtained in the same way, so that the cache data is input to the output area according to the intermediate data index numbers, to obtain the output data.

[0042] Further, the data security device is further used for:

[0043] The output data is copied to the cache area;

[0044] The data in the cache area is reversed to obtain the cache data;

[0045] Except for the last data in the cache data, the first data and the second data are taken out from the cache data in sequence, wherein the first data and the second data are adjacent;

[0046] The data index number of the first data is determined according to the second data and the obfuscation value, specifically including: x=(d[a+1]^SV)%(a+1), wherein x represents the data index number of the first data, d[a+1] represents the second data, ^ represents XOR calculation, SV represents the obfuscation value, % represents remainder calculation, a represents the label of the first data in the cache data, and a+1 represents the label of the second data in the cache data;

[0047] The first data is input to the output area according to the data index number of the first data, and finally, the last data in the cache data is input to the output area as the first data of the output data, and the existing data in the output area is moved one position backward.

[0048] Further, the data security device is further used for:

[0049] The first data in the cache data is input to the output area according to the data index number of the first data;

[0050] input the second data in the cache data to the output area according to the data index number of the first data of the second round input;

[0051] determine the data index number of the first data of the second round input according to the second data of the second round input and the confusion value;

[0052] input the second data in the cache data to the output area according to the data index number of the first data of the second round input;

[0053] In this way, except for the last data in the cache data, the data in the corresponding position of the cache data is input to the output area according to the data index number of the first data of each round input, wherein, when inputting the data each time, the data in the position corresponding to the data index number of the first data of each round input and the data after the position are moved one position backward.

[0054] In a third aspect, an embodiment of the present application provides a computer device, which comprises a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, and the processor executes the computer readable instructions to perform the steps of the data security method according to the first aspect.

[0055] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer readable instructions, and the computer readable instructions are executed by a processor to implement the steps of the data security method according to the first aspect.

[0056] In the embodiment of the present application, first, the original data is acquired, and the original data is copied to a cache area to obtain cache data, so that the original data is encrypted and protected by the cache area; then, the first data of the cache data is taken as the first data of the output data, so that the data is selected from the head of the array and output to the output area, and the data is convenient for restoration; then, the data index number is determined according to the first data of the cache data, so that the data is selected according to the data index number each time, and the data is input to the output area according to the data index number; finally, the cache data is input to the output area according to the data index number, to obtain the output data. The present application can generate the output data by disarranging the original data according to the data index number, and supports restoring the output data to the original data, can improve information security, and changes the sensitive plaintext data in the binary file into ciphertext data for protection. BRIEF DESCRIPTION OF DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. Obviously, the drawings described in the following embodiments are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.

[0058] Figure 1 is a data flow diagram of data encryption in the embodiments of the present application;

[0059] Figure 2 is another data flow diagram of data encryption in the embodiments of the present application;

[0060] Figure 3 is a data flow diagram of data decryption in the embodiments of the present application;

[0061] Figure 4 is another data flow diagram of data decryption in the embodiments of the present application;

[0062] Figure 5 is a data flow diagram of data encryption in the embodiments of the present application Figure 4 is a data flow diagram of inserting d[n-2] into the output area in the embodiments of the present application;

[0063] Figure 6 is a device principle block diagram corresponding to the data security method in the embodiments of the present application;

[0064] Figure 7 is a schematic diagram of a computer device in the embodiments of the present application. DETAILED DESCRIPTION

[0065] In order to better understand the technical solutions of the present application, the embodiments of the present application will be described in detail in combination with the drawings.

[0066] It should be clear that the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort belong to the scope of protection of the present application.

[0067] The terms used in the embodiments of the present application are only for the purpose of describing the specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise.

[0068] It should be understood that the term "and / or" used herein is merely a description of the same field of associated objects, which means that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist together, and B exists alone. In addition, the character " / " herein generally represents an "or" relationship between the associated objects before and after it.

[0069] It should be understood that although the terms first, second, third, etc. may be used in embodiments of the present application to describe a predetermined range, etc., these predetermined ranges should not be limited to these terms. These terms are only used to distinguish the predetermined ranges from each other. For example, the first predetermined range can also be referred to as the second predetermined range, and similarly, the second predetermined range can also be referred to as the first predetermined range, without departing from the scope of the embodiments of the present application.

[0070] Depending on the context, the word "if" as used herein can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting". Similarly, depending on the context, the phrase "if it is determined" or "if (a stated condition or event) is detected" can be interpreted as "when it is determined" or "in response to determining" or "when (a stated condition or event) is detected" or "in response to detecting (a stated condition or event)".

[0071] The present application provides a data security method. The data security method is applied in the scene of file information security, and a user can protect a file in a binary storage mode, such as an embedded program file, by using the data security method, to prevent leakage of file information. The data security method comprises the following steps:

[0072] S10: Obtain original data.

[0073] The original data can be data stored in a binary mode in a bin file. Some sensitive plaintext data, such as software information, parameter information, and key information, exist in the data. These sensitive plaintext data need to be secured to prevent third parties from opening the bin file by using a binary tool to obtain these data.

[0074] S20: Copy the original data to a cache area to obtain cache data.

[0075] The cache area can be understood as a data storage space for transit processing of data. In this way, the original data is not directly destroyed, and the original data can be secured.

[0076] S30: Take the first data of the cache data as the first data of the output data.

[0077] In an embodiment, the cached data in the cache area can be in the form of an array data structure. The first data in the cached data can be d[0] in the array, i.e., the data stored in the 0th value position. Figure 1 is a data flow diagram for data encryption in an embodiment of the present application, as shown in Figure 1 The in_array (input array, here specifically referring to original data) is copied to the buffer_array (buffer array, here specifically referring to the cache area), and the first data d[0] of the buffer_array is input to the first array position of the out_array (output array, here specifically referring to the output area) as the first data D[0] of the out_array. In the embodiment of the present application, the first data of the cached data is taken as the first data of the output data, which can be output to the output area from the head of the array using the confusion value, and is convenient for data restoration.

[0078] S40: determining a data index number according to the first data of the cached data and the confusion value.

[0079] In the embodiment of the present application, the confusion value (SaltVal, abbreviated as SV) is used to disrupt the output order of the data to be output, which can be a random number.

[0080] The data index number is the position information referred to when the cached data is input to the output area. It can be understood that the data in the cached data is input to the output area one by one, and each time the data is input has a certain randomness due to the processing of the confusion value. In the embodiment of the present application, the randomness can come from the data index number that changes each time, for example, the data index number changes each time according to the data index number of the last input data, then the first data of the cached data will be determined as the first data index number to determine the following data index numbers, so as to achieve the effect of disrupting the input of the cached data to the output area.

[0081] S50: inputting the cached data to the output area according to the data index number to obtain output data.

[0082] In the embodiment of the present application, first, the original data is acquired, and the original data is copied to the cache area to obtain cache data, so as to encrypt and protect the original data through the cache area; then, the first data of the cache data is taken as the first data of the output data, so as to select the data from the head of the array and output the data to the output area, and facilitate data restoration; then, the data index number is determined according to the first data of the cache data, so as to select the data output each time according to the data index number, and input the data to the output area according to the data index number; finally, the cache data is input to the output area according to the data index number, to obtain the output data. The present application can generate the output data by scrambling the original data according to the data index number, and supports restoring the output data to the original data, can improve information security, and changes the sensitive plaintext data in the binary file into ciphertext data for protection.

[0083] Further, in step S40, that is, the step of determining the data index number according to the first data of the cache data and the confusion value, specifically includes the following steps:

[0084] S41: taking the array position of the first data of the cache data as the initial data index number.

[0085] In an embodiment, the first data of the cache data is not only taken as the first data of the output data, but also the array position d[0] (the first data in the cache data, numbered from 0) of the first data is taken as the initial data index number, so as to calculate the data index number of the next data input to the output area through the initial data index number.

[0086] S42: acquiring the intermediate data index number according to the confusion value and the initial data index number, wherein, after inputting the data from the cache data to the output area each time, the cache data deletes the data input at this time, and the array length of the cache area is reduced by one, and the intermediate data index number is the index number determined after the array length of the cache area changes each time, so as to determine the data input to the output area next time according to the intermediate data index number.

[0087] The intermediate data index number is a relative concept, because the array length of the cache area in the embodiment of the present application is reduced by one after inputting the data to the output area each time, and because the data index number of the cache area after the array length is shortened each time changes according to the data index number corresponding to the last cache area, the data index number corresponding to the cache area after the array length is shortened each time is called the intermediate data index number.

[0088] In an embodiment, the intermediate data index number can determine the data to be input to the output area next time after the cache area changes each time, and the intermediate index number is acquired by changing the confusion value and the initial data index number in the process of shortening the array length of the cache area many times, has traceability, and the user can use the feature to restore the original data after data encryption.

[0089] Further, in step S42, i.e. the step of obtaining the intermediate data index number according to the confusion value and the initial data index number, the step specifically comprises the following steps:

[0090] S421: XORing the data corresponding to the confusion value and the initial data index number to obtain a first XOR value.

[0091] The data corresponding to the initial data index number refers to the first data in the cache data.

[0092] S422: dividing the first XOR value by the length of the cache area and taking the remainder to obtain a first intermediate data index number.

[0093] S423: XORing the data corresponding to the confusion value and the first intermediate data index number to obtain a second XOR value.

[0094] The data corresponding to the first intermediate data index number refers to the second data taken from the cache data, and the data corresponding to the second intermediate data index number refers to the third data taken from the cache data.

[0095] S424: dividing the second XOR value by the length of the changed cache area and taking the remainder to obtain a second intermediate data index number, and the remaining intermediate data index numbers are obtained in the same way, so that the cache data is input to the output area according to the intermediate data index number to obtain output data.

[0096] In steps S421-S424, the following formula can be used for generalization: x=(d[x]^SV) % n, where x is the current data index number to be taken out, d[x] represents the last data taken out, ^ represents XOR calculation, SV is the confusion value, which can be a preset random number, % is the remainder calculation, and n is the array length of the last cache area. The formula can be used to determine the data index number of the cache area after the array length is shortened each time, i.e. the intermediate data index number.

[0097] Figure 2 is another data encryption data flow diagram in the embodiment of the application, as shown in Figure 2 n represents the array length of the new cache area (the array length of the changed cache area), the length of the cache area is reduced by 1 after the data in the cache area is input to the output area (from old buffer_array to new buffer_array), and the next data to be output is found from the array of the cache area according to the data index number calculated by x=(d[x]^SV) % n, and the data in the cache area is input to the output area in a disordered manner.

[0098] Further, after step S50, i.e. after the output data is obtained, the data security method further comprises the following steps:

[0099] The encrypted data is restored to the original data. Specifically:

[0100] S51: The output data is copied to the buffer area.

[0101] It should be noted that the buffer area is a storage concept, and the buffer area mentioned above for copying the original data to the buffer area can be the same storage space in physical location, or can be a different storage space in physical location, as long as it is used to store the data in the intermediate state.

[0102] S52: The data in the buffer area is operated in reverse order to obtain the cache data.

[0103] It should be noted that since the subsequent data needs to be moved backward when inserted into the output area during the restoration process, the reverse operation can reduce more calculations when restoring data, and there is no need to adjust the position of the inserted data.

[0104] Figure 3 is a data flow diagram of data restoration in an embodiment of the present application, as shown in Figure 3 The data in the buffer area is operated in reverse order to obtain the cache data. It should be noted that the data in the in_array in the figure is the original encrypted data, which can be directly output in reverse order to the buffer_array as in_array (input array, here specifically referring to the encrypted data), or the data in the in_array can be first copied to the buffer_array1 and then output in reverse order to the buffer_array2. The specific data operation is not limited, as long as the data in the buffer area is the original encrypted data obtained by reversing.

[0105] S53: Except for the last data in the cache data, the first data and the second data are taken out from the cache data in order each time, wherein the first data and the second data are adjacent.

[0106] It can be understood that if the length of the cache data is n, the cache data includes data d[0]-d[n-1], and taking out the first data and the second data from the cache data in order each time can be understood as taking out two adjacent data from the cache data in order each time, such as taking out d[0] and d[1] the first time, d[1] and d[2] the second time, d[2] and d[3] the third time, and so on until d[n-3] and d[n-2] are stopped.

[0107] S54: determining the data index number of the first data according to the second data and the confusion value, specifically comprising: x=(d[a+1]^SV)%(a+1), wherein x represents the data index number of the first data, d[a+1] represents the second data (and d[a] represents the first data), ^ represents XOR calculation, SV represents the confusion value, % represents remainder calculation, and a represents the label of the first data in the cache data, and a+1 represents the label of the second data in the cache data.

[0108] In the above process, the confusion value used in the data encryption process is the same as the confusion value used in the data index number determination process.

[0109] In the above process, the confusion value used in the data encryption process is the same as the confusion value used in the data index number determination process.

[0110] In an embodiment, the data index number of the first data determines the specific position of the first data input into the output area, and the data index number of the first data is calculated according to the second data adjacent to the first data by x=(d[a+1]^SV)%(a+1), so that the position of the first data input into the output area can be determined by using the second data.

[0111] S55: inputting the first data into the output area according to the data index number of the first data, and finally, inputting the last data in the cache data into the output area as the first data of the output data, and moving the data already existing in the output area by one position.

[0112] Further, in step S55, i.e., inputting the first data into the output area according to the data index number of the first data, specifically comprising the following steps:

[0113] S551: inputting the first data in the cache data into the output area according to the data index number of the first data.

[0114] S552: taking the second data as the first data of the second round, and taking the data adjacent to the first data of the second round in the cache data as the second data of the second round.

[0115] S553: determining the data index number of the first data of the second round according to the second data of the second round and the confusion value.

[0116] S554: inputting the second data in the cache data into the output area according to the data index number of the first data of the second round.

[0117] S555: Similarly, except for the last data in the cache data, the data in the corresponding position of the cache data is input to the output area according to the data index number of the first data input in each round, wherein the data index number corresponding position and the data after the first data are moved one position backward each time the data is input.

[0118] In steps S551-S555, in the data restoration process, the data is inserted into the output area one by one by using the data insertion method. Similarly, similar to the data encryption process, the data index number of the first data inserted into the output area is changed each time, and the calculation method of the data index number of the first data can be represented by the following formula: x = (d[a+1]^SV)%(a+1), so that the position of the first data to be input to the output area can be determined by using the second data.

[0119] Figure 4 is another data flow diagram for data restoration in an embodiment of the present application, as shown in Figure 4 the data index number of the first data calculated according to the formula x = (d[a+1]^SV)%(a+1) is used to determine the data to be inserted into the output area each time. By analogy, the data with a total length of n-1 before the cache area is inserted into the output area, wherein the data index number corresponding position and the data after the first data are moved one position backward each time the data in the cache area is inserted.

[0120] Figure 5 is another data flow diagram for data restoration in an embodiment of the present application Figure 4 after d[n-2] is inserted into the output area, as shown in Figure 5 the last data d[n-1] in the cache area is inserted into the first array position of the output area, and the other inserted data is moved one position backward, so that the data processing process of Figure 4 can restore the encrypted original data.

[0121] In an embodiment of the present application, the original data is first obtained, and the original data is copied to the cache area to obtain cache data, so as to encrypt and protect the original data through the cache area; then the first data of the cache data is taken as the first data of the output data, so as to select the data from the head of the array and output to the output area, and facilitate data restoration; then the data index number is determined according to the first data of the cache data, so as to select the data output each time according to the data index number, and the data is input to the output area according to the data index number; finally, the cache data is input to the output area according to the data index number to obtain the output data. The present application can generate the output data by scrambling the original data according to the data index number, and support the output data to be restored to the original data, so as to improve the information security and protect the sensitive plaintext data in the binary file into ciphertext data.

[0122] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the application.

[0123] Figure 6 is a device principle block diagram corresponding to a data security method in the embodiments of the application. The data security device includes a first acquisition module 10, a second acquisition module 20, a first determination module 30, a second determination module 40, and a third acquisition module 50.

[0124] The first acquisition module 10 is configured to acquire original data.

[0125] The second acquisition module 20 is configured to copy the original data to a cache area to obtain cache data.

[0126] The first determination module 30 is configured to take the first data of the cache data as the first data of output data.

[0127] The second determination module 40 is configured to determine a data index number according to the first data of the cache data and a confusion value.

[0128] The third acquisition module 50 is configured to input the cache data to an output area according to the data index number to obtain output data.

[0129] Further, the second determination module 40 is specifically configured to:

[0130] take the array position of the first data of the cache data as an initial data index number;

[0131] obtain an intermediate data index number according to the confusion value and the initial data index number, wherein after each time data is input from the cache data to the output area, the cache data deletes the data input at the time, and the array length of the cache area is reduced by one, and the intermediate data index number is the index number determined after the array length of the cache area changes each time, so as to determine the data input to the output area next time according to the intermediate data index number.

[0132] Further, the second determination module 40 is specifically configured to:

[0133] perform exclusive or operation on the data corresponding to the confusion value and the initial data index number to obtain a first exclusive or value;

[0134] obtain a first intermediate data index number by taking the first exclusive or value as a modulus of the length of the cache area;

[0135] perform exclusive or operation on the data corresponding to the confusion value and the first intermediate data index number to obtain a second exclusive or value;

[0136] The second intermediate data index number is obtained by dividing the second XOR value by the length of the changed cache area and taking the remainder, and the remaining intermediate data index numbers are obtained in the same way, so that the cache data is input to the output area according to the intermediate data index numbers, and the output data is obtained.

[0137] Further, the data security device is also specifically used for:

[0138] copying the output data to the cache area;

[0139] performing reverse operation on the data in the cache area to obtain cache data;

[0140] except for the last data in the cache data, the first data and the second data are taken out from the cache data in order each time, wherein the first data and the second data are adjacent;

[0141] determining the data index number of the first data according to the second data and the confusion value, specifically including: x = (d[a+1]^SV)%(a+1), wherein x represents the data index number of the first data, d[a+1] represents the second data, ^ represents XOR calculation, SV represents the confusion value, % represents remainder calculation, a represents the label of the first data in the cache data, and a+1 represents the label of the second data in the cache data;

[0142] inputting the first data to the output area according to the data index number of the first data, and finally, inputting the last data in the cache data to the output area as the first data of the output data, and moving the data already existing in the output area by one position.

[0143] Further, the data security device is also specifically used for:

[0144] inputting the first data in the cache data to the output area according to the data index number of the first data;

[0145] taking the second data as the first data of the second round of input, and taking the data adjacent to the first data of the second round of input in the cache data as the second data of the second round of input;

[0146] determining the data index number of the first data of the second round of input according to the second data of the second round of input and the confusion value;

[0147] inputting the second data in the cache data to the output area according to the data index number of the first data of the second round of input;

[0148] In the same way, except for the last data in the cache data, the data in the corresponding position in the cache data is input to the output area according to the data index number of the first data of each round of input, wherein the data after the data index number of the first data of each round of input is moved by one position each time the data is input.

[0149] In the embodiment of the present application, the original data is first acquired and copied to a cache area to obtain cache data, so that the original data is encrypted and protected by the cache area; then the first data of the cache data is taken as the first data of the output data, so that the data is selected from the head of the array and output to the output area, and data restoration is facilitated; then the data index number is determined according to the first data of the cache data, so that the data output each time is selected according to the data index number, and the data is input to the output area according to the data index number; finally, the cache data is input to the output area according to the data index number to obtain the output data. The present application can generate the output data by scrambling the original data according to the data index number, and supports restoring the output data to the original data, so that the information security is improved, and the sensitive plaintext data in the binary file is changed into ciphertext data for protection.

[0150] The embodiment of the present application also provides a computer readable storage medium, which stores computer readable instructions, and the computer readable instructions are executed by a processor to realize the steps of the data security method according to the embodiment.

[0151] Figure 7 is a schematic diagram of a computer device in the embodiment of the present application.

[0152] As shown in Figure 7 , the computer device 110 includes a processor 111, a memory 112, and computer readable instructions 113 stored in the memory 112 and executable on the processor 111. The processor 111 executes the computer readable instructions 113 to realize the steps of the data security method.

[0153] Exemplarily, the computer readable instructions 113 can be divided into one or more modules / units, which are stored in the memory 112 and executed by the processor 111 to complete the present application. The one or more modules / units can be a series of computer readable instruction segments capable of completing a specific function, which are used to describe the execution process of the computer readable instructions 113 in the computer device 110.

[0154] The computer device 110 can be a desktop computer, a notebook computer, a palm computer, a cloud server and the like. The computer device can include, but is not limited to, the processor 111 and the memory 112. Those skilled in the art can understand that Figure 7 The computer device 110 is only an example and does not constitute a limitation on the computer device 110, and can include more or fewer components than the diagram, or combine certain components, or different components, for example, the computer device can also include an input / output device, a network access device, a bus and the like.

[0155] The processor 111 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0156] The memory 112 can be an internal storage unit of the computer device 110, for example, a hard disk or a memory of the computer device 110. The memory 112 can also be an external storage device of the computer device 110, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 112 can include both the internal storage unit and the external storage device of the computer device 110. The memory 112 is used to store computer readable instructions and other programs and data required by the computer device. The memory 112 can also be used to temporarily store data that has been output or will be output.

[0157] Embodiments of the present application can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0158] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. The software technology of artificial intelligence mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.

[0159] In the embodiments of the present application, the server can be a stand-alone server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0160] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, 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 a software functional unit.

[0161] The integrated module / unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by computer-readable instructions instructing related hardware, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed by a processor, the steps of each method embodiment described above can be implemented. The computer-readable instructions include computer-readable instruction codes, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer-readable medium can include any entity or device, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. that can carry the computer-readable instructions. It should be noted that the contents included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0162] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is taken as an example for illustration, and in actual applications, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.

[0163] The above examples are only used to illustrate the technical solutions of the present application, but not limit the same; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that the technical solutions recorded in the foregoing examples can be modified, or some technical features can be replaced by equivalent ones; 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 present application, and should be included in the protection scope of the present application.

Claims

1. A data security method characterized by, The method comprises: obtaining original data; copying the original data to a cache area to obtain cache data; taking the first data of the cache data as the first data of output data; determining a data index number according to the first data of the cache data and a confusion value, comprising: taking the array position of the first data of the cache data as an initial data index number; obtaining an intermediate data index number according to the confusion value and the initial data index number, wherein, after each time data is input from the cache data to an output area, the cache data is deleted and the array length of the cache area is reduced by one, the intermediate data index number is determined after the array length of the cache area changes each time, and the next data input to the output area is determined according to the intermediate data index number; the method of obtaining an intermediate data index number according to the confusion value and the initial data index number comprises: performing XOR operation on the data corresponding to the confusion value and the initial data index number to obtain a first XOR value; dividing the first XOR value by the length of the cache area and taking the remainder to obtain a first intermediate data index number; performing XOR operation on the data corresponding to the confusion value and the first intermediate data index number to obtain a second XOR value; dividing the second XOR value by the length of the cache area after the length changes and taking the remainder to obtain a second intermediate data index number, and the remaining intermediate data index numbers are obtained in the same way; inputting the cache data to the output area according to the intermediate data index number to obtain the output data.

2. The method of claim 1, wherein, After the output data is obtained, the method further comprises: copying the output data to the cache area; performing reverse order operation on the data in the cache area to obtain the cache data; except for the last data in the cache data, taking out the first data and the second data from the cache data in order each time, wherein the first data and the second data are adjacent; determining the data index number of the first data according to the second data and the confusion value, specifically comprising: x = (d[a+1] ^ SV) % (a+1), wherein x represents the data index number of the first data, d[a+1] represents the second data, ^ represents XOR calculation, SV represents the confusion value, % represents remainder calculation, a represents the label of the first data in the cache data, and a+1 represents the label of the second data in the cache data; inputting the first data to the output area according to the data index number of the first data, and finally, inputting the last data in the cache data to the output area as the first data of the output data, wherein the data already existing in the output area are all moved one position backward.

3. The method of claim 2, wherein, the method of inputting the first data to the output area according to the data index number of the first data comprises: inputting the first data in the cache data to the output area according to the data index number of the first data; input the first data of each round as the second data of the next round, and obtain the data adjacent to the first data of the next round in the cache data as the second data of the next round; determine the data index number of the first data of the next round according to the second data of the next round and the confusion value; input the second data in the cache data to the output area according to the data index number of the first data of the next round; By analogy, except for the last data in the cache data, input the data at the corresponding position in the cache data to the output area according to the data index number of the first data of each round, wherein, when inputting data each time, the data at the position corresponding to the data index number of the first data of each round and the data after the position are moved one position backward.

4. A data security apparatus, characterized by comprising: Comprise: The first acquisition module is used for acquiring original data. The second acquisition module is used for copying the original data to a cache area to obtain cache data. The first determination module is used for taking the first data of the cache data as the first data of output data. The second determination module is used for determining a data index number according to the first data of the cache data and a confusion value. In terms of determining the data index number according to the first data of the cache data and the confusion value, the second determination module is specifically used for: taking the array position of the first data of the cache data as an initial data index number; obtaining an intermediate data index number according to the confusion value and the initial data index number, wherein, after inputting data from the cache data to the output area each time, the cache data is deleted and the array length of the cache area is reduced by one, and the intermediate data index number is the index number determined after the array length of the cache area changes each time, so as to determine the data input to the output area next time according to the intermediate data index number; In terms of obtaining the intermediate data index number according to the confusion value and the initial data index number, the second determination module is specifically used for: performing exclusive or operation on the data corresponding to the confusion value and the initial data index number to obtain a first exclusive or value; obtaining a first intermediate data index number by taking the first exclusive or value as a remainder after the length of the cache area is divided; performing exclusive or operation on the data corresponding to the confusion value and the first intermediate data index number to obtain a second exclusive or value; obtaining a second intermediate data index number by taking the second exclusive or value as a remainder after the length of the cache area after the length change is divided, and obtaining the remaining intermediate data index numbers by analogy; The third acquisition module is used for inputting the cache data to the output area according to the intermediate data index number to obtain the output data.

5. A computer device comprising a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein, The processor executes the computer readable instructions to execute the steps of the data security method in any one of claims 1-3.

6. A computer-readable storage medium having stored computer-readable instructions, wherein, The computer readable instructions are executed by the processor to implement the steps of the data security method in any one of claims 1-3.

Citation Information

Patent Citations

  • Hierarchical encryption / decryption device and method thereof

    CN102752101A

  • Data processing method and device, storage medium and electronic equipment

    CN111090628A