Configuration file coding method and device, configuration file decoding method and device and electronic equipment

By reading, serializing and traversing the configuration file, generating obfuscated arrays for encoding, the problem of easy-to-break configuration files is solved and data security and confidentiality are improved.

CN118981341APending Publication Date: 2024-11-19CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411087728.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

In the prior art, configuration files are easily cracked, resulting in poor data security, especially in the process of password storage and encryption.

Method used

By obtaining the configuration file, reading and serializing the object, generating a byte array, traversing and converting it, the converted string is obtained, and then the obfuscation array is generated according to the length of the converted string, and the configuration file is obfuscated and encoded. , generate an encoded file.

Benefits of technology

Improves data security and reduces the risk of data breaches by converting plaintext data into encoded files that are difficult to identify and understand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981341A_ABST
    Figure CN118981341A_ABST
Patent Text Reader

Abstract

The invention discloses a configuration file encoding method, a configuration file decoding method, a configuration file encoding device, a configuration file decoding device and electronic equipment. The method comprises the following steps: acquiring a configuration file, performing object reading processing on the configuration file, generating a configuration object, and performing serialization processing on the configuration object to obtain a byte array; traversing and converting the byte array to obtain a converted character string; and generating a confusion array through the server according to the length of the converted character string, and performing confusion coding processing on the converted character string according to the confusion array to obtain a coded file. The data security of the configuration file can be improved, and the method can be widely applied to the technical field of computers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a configuration file encoding method, decoding method, device and electronic device. Background Art

[0002] During software development, configuration files are usually placed in the directory where the software is located on the server. They are in plain text and can be easily obtained by other users. In the related art, there is a method of encrypting the configuration files with passwords, that is, entering the correct password to obtain the configuration files. However, in actual applications, it is found that the storage of passwords may also be leaked, which makes the configuration files easy to be cracked, affecting the security of data.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to provide a configuration file encoding method, decoding method, device and electronic device, which can improve the security of data.

[0005] To achieve the above object, an embodiment of the present application provides a configuration file encoding method in one aspect, the method comprising:

[0006] Get the configuration file;

[0007] Performing object reading processing on the configuration file to generate a configuration object;

[0008] Serializing the configuration object to obtain a byte array;

[0009] Traversing and converting the byte array to obtain a converted string;

[0010] Generate an obfuscation array through the server according to the length of the converted string;

[0011] The conversion character string is subjected to obfuscation encoding processing according to the obfuscation array to obtain an encoded file.

[0012] In some embodiments, the traversing and converting the byte array to obtain a converted string includes the following steps:

[0013] Get a first index value and a second index value; the first index value is an index value corresponding to the first value of the byte array, and the second index value is a value obtained by adding one to the first index value;

[0014] Search the byte array according to the first index value and the second index value to obtain a first value and a second value; the first value is the byte value corresponding to the first index value, and the second value is the byte value corresponding to the second index value;

[0015] Let the first value be equal to the XOR value of the first value and the second value;

[0016] Add one to the first index value and the second index value, and return to searching the byte array according to the first index value and the second index value until the second index value is equal to the index value corresponding to the last value of the byte array, thereby obtaining a traversed array;

[0017] Perform string conversion processing on the traversal array to obtain a converted string.

[0018] In some embodiments, generating an obfuscation array by a server according to the length of the converted string comprises the following steps:

[0019] Randomly select the static files on the server to obtain selected files;

[0020] Performing random position reading processing on the selected file to obtain a read byte set;

[0021] The read byte set is appended and merged according to the length of the converted string to obtain a confusion array.

[0022] In some embodiments, the appending and merging processing is performed on the read byte set according to the length of the converted string to obtain an obfuscated array, comprising the following steps:

[0023] Performing alternating hash processing on the bytes in the read byte set to obtain a hash array;

[0024] Performing serial merging processing on the hash values ​​of the hash array to obtain a hash value array;

[0025] The hash value array is extracted and processed according to the length of the converted string to obtain an obfuscated array.

[0026] In some embodiments, performing obfuscated encoding processing on the converted string according to the obfuscated array to obtain an encoded file includes the following steps:

[0027] Perform random character insertion processing on the conversion string according to the obfuscation array to obtain an obfuscated string;

[0028] The obfuscated character string is encoded to obtain an encoded file.

[0029] In some embodiments, performing random character insertion processing on the converted string according to the obfuscation array to obtain the obfuscated string includes the following steps:

[0030] Obtaining random characters, wherein the format of the random characters is the same as that of the converted character string;

[0031] Determine the index position according to the value of the obfuscated array;

[0032] The random characters are inserted into the converted character string according to the index position to obtain an obfuscated character string.

[0033] To achieve the above object, another aspect of an embodiment of the present application provides a configuration file decoding method, the decoding method comprising the following steps:

[0034] Get the encoded file and obfuscated array;

[0035] According to the obfuscation array, the encoded file is subjected to obfuscated character removal processing to obtain a converted character string;

[0036] Performing conversion and restoration processing on the conversion string to obtain a byte array;

[0037] The byte array is deserialized to obtain a configuration object.

[0038] To achieve the above object, another aspect of an embodiment of the present application provides a configuration file encoding device, the encoding device comprising:

[0039] The first module is used to obtain the configuration file;

[0040] The second module is used to perform object reading processing on the configuration file to generate a configuration object;

[0041] The third module is used to serialize the configuration object to obtain a byte array;

[0042] The fourth module is used to traverse and convert the byte array to obtain a converted string;

[0043] A fifth module is used to generate an obfuscation array through a server according to the length of the conversion string;

[0044] The sixth module is used to perform obfuscation encoding processing on the conversion string according to the obfuscation array to obtain an encoded file.

[0045] In some embodiments, the fourth module is used to traverse and convert the byte array to obtain a converted string, including:

[0046] A first unit is used to obtain a first index value and a second index value; the first index value is an index value corresponding to a first value of the byte array, and the second index value is a value obtained by adding one to the first index value;

[0047] A second unit is used to search the byte array according to the first index value and the second index value to obtain a first value and a second value; the first value is the byte value corresponding to the first index value, and the second value is the byte value corresponding to the second index value;

[0048] A third unit is used to make the first value equal to an exclusive OR value of the first value and the second value;

[0049] A fourth unit is used to add one to the first index value and the second index value, and return to the step of searching the byte array according to the first index value and the second index value until the second index value is equal to the index value corresponding to the last value of the byte array, so as to obtain a traversed array;

[0050] The fifth unit is used to perform string conversion processing on the traversal array to obtain a converted string.

[0051] In some embodiments, the fifth module is used to generate an obfuscation array through the server according to the length of the converted string, including:

[0052] The sixth unit is used to randomly select the static files of the server to obtain the selected files;

[0053] A seventh unit is used for performing random position reading processing on the selected file to obtain a read byte set;

[0054] The eighth unit is used to perform appending and merging processing on the read byte set according to the length of the converted string to obtain a confusion array.

[0055] In some embodiments, the eighth unit is used to perform appending and merging processing on the read byte set according to the length of the converted string to obtain an obfuscated array, including:

[0056] A first subunit is used to perform alternating hash processing on bytes in the read byte set to obtain a hash array;

[0057] A second subunit is used to perform serial merging processing on the hash values ​​of the hash array to obtain a hash value array;

[0058] The third subunit is used to extract the hash value array according to the length of the converted string to obtain an obfuscated array.

[0059] In some embodiments, the sixth module is used to perform obfuscated encoding processing on the converted string according to the obfuscated array to obtain an encoded file, including:

[0060] A ninth unit is used for performing random character insertion processing on the conversion string according to the obfuscation array to obtain an obfuscated string;

[0061] The tenth unit is used to encode the obfuscated character string to obtain an encoded file.

[0062] In some embodiments, the ninth unit is used to perform random character insertion processing on the converted string according to the obfuscation array to obtain the obfuscated string, including:

[0063] A fourth subunit is used to obtain random characters, wherein the random characters have the same format as the converted character string;

[0064] A fifth subunit, configured to determine an index position according to a value of the obfuscated array;

[0065] The sixth subunit is configured to insert the random character into the converted character string according to the index position to obtain an obfuscated character string.

[0066] To achieve the above object, another aspect of an embodiment of the present application provides a configuration file decoding device, the decoding device comprising:

[0067] The seventh module is used to obtain the encoded file and obfuscation array;

[0068] An eighth module is used to remove obfuscated characters from the encoded file according to the obfuscation array to obtain a converted character string;

[0069] A ninth module is used to convert and restore the converted character string to obtain a byte array;

[0070] The tenth module is used to perform deserialization processing on the byte array to obtain a configuration object.

[0071] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the encoding method or decoding method described above when executing the computer program.

[0072] To achieve the above objectives, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the encoding method or decoding method described above is implemented.

[0073] The embodiments of the present application include at least the following beneficial effects: the present application provides a configuration file encoding method, decoding method, device and electronic device, which obtains a configuration file, performs object reading processing on the configuration file, generates a configuration object, serializes the configuration object, and obtains a byte array. After the plaintext data is converted into a byte array, it can be further encrypted, thereby improving the security of the data; in addition, the present solution traverses and converts the byte array to obtain a conversion string, which can clear the serialization information and improve the security of the data; furthermore, the present solution also generates an obfuscation array through the server according to the length of the conversion string, performs obfuscation encoding processing on the conversion string according to the obfuscation array, and obtains an encoded file. The obfuscation array generated by the server can make the original structure and content of the conversion string difficult to identify and understand, thereby improving the security of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 is a flow chart of a configuration file encoding method provided by an embodiment of the present application;

[0075] Figure 2 yes Figure 1 Flow chart of step S104 in FIG.

[0076] Figure 3 yes Figure 1 Flow chart of step S105 in FIG.

[0077] Figure 4 yes Figure 3 Flow chart of step S303 in FIG.

[0078] Figure 5 yes Figure 1 Flow chart of step S106 in FIG.

[0079] Figure 6 yes Figure 5 Flow chart of step S501 in FIG.

[0080] Figure 7 is a flow chart of a configuration file decoding method provided by an embodiment of the present application;

[0081] Figure 8 is a schematic diagram of the structure of a configuration file encoding device provided in an embodiment of the present application;

[0082] Fig. 9 is a structural diagram of a configuration file decoding device provided in an embodiment of the present application;

[0083] Fig.10 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0084] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0085] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0086] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0087] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0088] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0089] 1) Configuration file (Configuration file), in the field of computer science, is a computer file that can configure parameters and initial settings for some computer programs, that is, a file that configures different objects differently.

[0090] 2) Advanced Encryption Standard (AES) is a block encryption standard that uses a fixed-length key to encrypt and decrypt data blocks. The encryption and decryption processes are based on operations such as matrix operations and byte substitution.

[0091] 3) Hash is a method of transforming an input of arbitrary length into an output of fixed length through a hash algorithm. The output is the hash value.

[0092] In the field of software development, in order to strengthen data security, measures taken for data include data encryption transmission, passwords with a minimum length of 8 characters, and a combination of uppercase and lowercase letters, special characters and numbers, and mandatory password changes every three months. However, few people consider how to strengthen configuration files. Generally, configuration files are placed in the directory where the server software is located or in the root directory. For data security, configuration files are also placed in a deeper directory. However, these configuration files are often in plain text and can be easily obtained by other users.

[0093] In the related art, there is a method of encrypting configuration files with passwords, that is, a specific password is required to obtain the corresponding configuration file. However, in actual applications, it is found that the password corresponding to the configuration file needs to be stored separately, which is easy to be cracked, and there is a possibility of data leakage, which affects the security of data.

[0094] For example, during the software development process, it is necessary to connect to a database, and put the database account and password into a configuration file. When the configuration file is obtained by other users, it is easy to use the information in the configuration file to obtain important data. In the related art, the configuration file is encrypted and stored, which can help improve the confidentiality of the configuration file. However, this method also requires the key to be saved, which is prone to data leakage. In the scenario of network attacks, passwords are often obtained, resulting in poor data security.

[0095] In view of this, the embodiments of the present application provide a configuration file encoding method, decoding method, device and electronic device. The scheme obtains a configuration file, performs object reading processing on the configuration file, generates a configuration object, and serializes the configuration object to obtain a byte array. After the plaintext data is converted into a byte array, it can be further encrypted, thereby improving the security of the data; in addition, the scheme traverses and converts the byte array to obtain a conversion string, which can clear the serialization information and improve the security of the data; further, the scheme also generates an obfuscation array through the server according to the length of the conversion string, and performs obfuscated encoding processing on the conversion string according to the obfuscated array to obtain an encoded file. The obfuscated array generated by the server can make the original structure and content of the conversion string difficult to identify and understand, thereby improving the security of the data.

[0096] A configuration file encoding method and decoding method provided in the embodiments of the present application relate to the field of computer technology. The configuration file encoding method and decoding method provided in the embodiments of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in a blockchain network; the software can be an application that implements the configuration file encoding method and decoding method, etc., but is not limited to the above forms.

[0097] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0098] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0099] Figure 1is an optional flowchart of a configuration file encoding method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S106.

[0100] Step S101, obtaining a configuration file;

[0101] Step S102, performing object reading processing on the configuration file to generate a configuration object;

[0102] Step S103, serializing the configuration object to obtain a byte array;

[0103] Step S104, traversing and converting the byte array to obtain a converted string;

[0104] Step S105, generating an obfuscation array through the server according to the length of the converted string;

[0105] Step S106, performing obfuscation encoding processing on the converted string according to the obfuscation array to obtain an encoded file.

[0106] Steps S101 to S106 shown in the embodiment of the present application are obtained by obtaining a configuration file, which is a configuration file in a software or program, such as a configuration file in an office software or a browser, and the configuration file contains the parameters and initial settings of a computer program. By performing object reading processing on the configuration file, a configuration object is obtained, and the configuration object may include computer parameters such as routing, middleware, and database connection. These configuration objects are then serialized, and the plaintext configuration object can be converted into a byte sequence to obtain a byte array, which is a set composed of a series of bytes. The byte array is then traversed and converted to obtain a conversion string, and the byte values ​​of the byte array are traversed and calculated, and the calculation results are replaced with the original byte values ​​to obtain a new byte array, which is then converted into a string of different formats, which can clear the serialization information in the byte, prevent the serialization method from being obtained, and further improve the security of the data. At this time, the length of the conversion string is obtained by the server to generate a corresponding obfuscation array, and the length of the obfuscation array is the same as the length of the conversion string, which is used to confuse the conversion string with random characters. The obfuscation array is generated by the server according to different rules. The rules generated by each server are different. The rules for generating the obfuscation array by the same server each time may also be different. The server is a server or computer software or program that needs to obtain the configuration file for corresponding software or program operation processing. At this time, the server is the requesting end. When the requesting end requests to obtain the configuration file, the generated obfuscation array will be sent to the responding end at the same time. The responding end will perform encoding processing according to the configuration file encoding method of the embodiment of the present application in combination with the obfuscation array to generate an encoded file. It can be imagined that the server in the embodiment of the present application is the end that needs to obtain the configuration file, which can be a computer, a computer program or software, etc., which is not limited here. The embodiment of the present application encodes the configuration file by generating an obfuscation array, which can convert the plaintext configuration file into a byte sequence, and then perform complex transformations through the obfuscation array, so that the original structure and content of the configuration file become difficult to identify and understand, thereby increasing the difficulty for attackers to obtain information through statistical analysis and other means, and improving the security and confidentiality of data.

[0107] In step S101 of some embodiments, with the permission or consent of the user, the configuration file may be obtained by accessing a standard library through a programming language, or by other means, such as obtaining the configuration file in a specific file format, but is not limited thereto.

[0108] In step S102 of some embodiments, the configuration file is subjected to object reading processing, and the key-value pairs in the configuration file can be mapped to the object attributes in the program, so that the configuration information can be conveniently obtained by accessing the object attributes, rather than directly operating the configuration file. Different programming languages ​​can be used to perform object reading processing on the configuration file to generate a configuration object, which contains specific parameters for operating data or programs, such as database name, database account, etc.

[0109] In step S103 of some embodiments, the configuration object is serialized to obtain a byte array, wherein the serialization method can use serialization tools such as messagepack and protobuf, wherein messagepack is an efficient binary serialization format. It can convert various data types, such as integers, strings, arrays, etc., into binary format for use during network transmission or storage. Protobuf (Protocol Buffers) is a language-neutral, platform-neutral, and extensible serialization data format. It is mainly used for the serialization and deserialization of structured data and is widely used in scenarios such as remote procedure calls (RPCs) and data storage. It should be noted that the embodiments of the present application try to use a serialization tool with compression, which can improve the processing efficiency of data. Since plaintext data is easily intercepted and parsed during data transmission, after converting the plaintext data into a byte array, encryption processing can be further performed to improve the security of the data. The byte array is a basic data structure in computer science for storing byte sequences. A byte is a unit of measurement used in computer information technology to measure storage capacity. It is usually represented by an 8-bit binary number with a value ranging from 0 to 255. A byte array is a collection of such bytes.

[0110] See also Figure 2 In step S104 of some embodiments, the traversal and conversion processing of the byte array to obtain a conversion string includes the following steps:

[0111] Step S201, obtaining a first index value and a second index value; the first index value is an index value corresponding to the first value of the byte array, and the second index value is a value obtained by adding one to the first index value;

[0112] Step S202, searching the byte array according to the first index value and the second index value to obtain a first value and a second value; the first value is the byte value corresponding to the first index value, and the second value is the byte value corresponding to the second index value;

[0113] Step S203, setting the first value equal to the XOR value of the first value and the second value;

[0114] Step S204, adding one to the first index value and the second index value, returning to the step of searching the byte array according to the first index value and the second index value until the second index value is equal to the index value corresponding to the last value of the byte array, thereby obtaining a traversed array;

[0115] Step S205, performing string conversion processing on the traversed array to obtain a converted string.

[0116] In the embodiment of the present application, it is necessary to traverse and convert the byte array, so as to clear the serialization information in the byte and further improve the security of the data. Specifically, the byte array is traversed to obtain the first index value and the second index value, the first index value is the index value corresponding to the first value in the byte array, that is, the first index value is 0, and the second index value is 1. Then the byte array is searched according to the first index value and the second index value to obtain the corresponding values, that is, the first value and the second value, the first value is the byte value corresponding to the first index value, and the second value is the byte value corresponding to the second index value. Then the first value is equal to the XOR value of the first value and the second value, that is, the XOR value of the first value and the second value is calculated, and the first value is equal to the XOR value. Then the first index value and the second index value are added by one respectively, at this time the first index value is 1, the second index value is 2, return to the first value and the second value according to the first index value and the second index value to obtain the first value and the second value, at this time the first value is the second value in the original byte array, and the above calculation steps are repeated until the second index value is the index value corresponding to the last value of the byte array, and the traversal of the byte array is completed to obtain the traversed array. It can be seen that the first value of the traversal array is the traversal calculation of the first value and the second value in the byte array, and the second value of the traversal array is the traversal calculation of the second value and the third value in the byte array, and so on. It can be imagined that in the embodiment of the present application, logical calculations such as XOR calculations can also be performed on the byte array, and arithmetic operations or bit operations can also be performed, but are not limited to this. Finally, the traversal array is subjected to string conversion processing, which can be converted into a hexadecimal string or a string of other bases. The embodiment of the present application can clear the serialization information in the byte array by traversing and converting the byte array, making it difficult for other users to obtain the serialization method, and further improving the security of the data.

[0117] See also Figure 3 In step S105 of some embodiments, generating an obfuscation array by the server according to the length of the converted string includes the following steps:

[0118] Step S301, randomly selecting static files on the server to obtain selected files;

[0119] Step S302, performing random position reading processing on the selected file to obtain a read byte set;

[0120] Step S303: append and merge the read byte set according to the length of the converted string to obtain a confusion array.

[0121] In an embodiment of the present application, the server generates an obfuscation array according to a specified rule, wherein the obfuscation array is derived from the byte value of the resource that the server can obtain, such as the server can read any one or more files of a length greater than 1k that will not change in the near future on the server, these files are collectively referred to as static files, and the static files may include pictures, scripts, etc. The bytecode can be read from any position in the static file, or the hash value in these files, or the combination of partial bytes of several files to obtain the obfuscation array. The embodiment of the present application provides a specific rule for generating an obfuscation array, firstly, the static file of the server is randomly selected to obtain the selected file, and then the selected file is read at a random position, for example, starting from the 256th position of the selected file, reading 32 bytes each time, and saving all the bytes obtained by reading to obtain a read byte set. It can be imagined that when the tail of the selected file is read, the reading process is continued from the beginning, and the number of reads can be set according to the actual situation, for example, it can be set to the length of the conversion string. Finally, the read bytes in the read byte set are appended and merged according to the length of the conversion string, and the bytes are merged and converted into a binary format to obtain a binary obfuscation array, which is used to perform random character insertion processing on the conversion string. The embodiment of the present application generates an obfuscation array through the server, which provides a data basis for subsequent obfuscation processing of the configuration file.

[0122] See also Figure 4 In step S303 of some embodiments, the appending and merging processing is performed on the read byte set according to the length of the converted string to obtain an obfuscated array, including the following steps:

[0123] Step S401, performing alternating hash processing on the bytes in the read byte set to obtain a hash array;

[0124] Step S402, performing serial merging processing on the hash values ​​of the hash array to obtain a hash value array;

[0125] Step S403: extracting the hash value array according to the length of the converted string to obtain an obfuscated array.

[0126] In an embodiment of the present application, the bytes in the read byte set are subjected to alternate hash processing, for example, the bytes in the read byte set are subjected to alternate hash processing of the md5 hash algorithm and the sha256 hash algorithm in sequence to obtain a hash array, and any two adjacent hash values ​​in the hash array are values ​​calculated using different hash algorithms. Then the hash values ​​of the hash array are subjected to serial merging processing, for example, each hash value of the hash array is directly spliced ​​until the number of bits after merging is greater than or equal to the length of the conversion string, to obtain a hash value array. It should be noted that each hash value in the hash array is in binary format. Then the hash value array is extracted according to the length of the conversion string to obtain a confusion array, the length of the confusion array is the same as the length of the conversion string, so that the conversion string can be subjected to random character insertion processing according to the confusion array. In an embodiment of the present application, a confusion array is generated according to the length of the conversion string, so that the length of the confusion array can be the same as the length of the conversion string, and the conversion string can be confused according to the index corresponding to the value of the confusion array, further improving the security of the data.

[0127] See also Figure 5 In step S106 of some embodiments, performing obfuscated encoding processing on the converted string according to the obfuscated array to obtain an encoded file includes the following steps:

[0128] Step S501, performing random character insertion processing on the conversion string according to the obfuscation array to obtain an obfuscated string;

[0129] Step S502: Encode the obfuscated character string to obtain an encoded file.

[0130] In an embodiment of the present application, the length of the obfuscation array is the same as the length of the conversion string. Random characters can be inserted into the corresponding positions of the conversion string according to the value of the obfuscation array to obtain an obfuscated string. The obfuscation array is in binary format. Finally, the obfuscated string is encoded. The encoding method can adopt the base64 encoding method, which is based on sixty-four printable characters to represent binary data. At this time, the hexadecimal conversion string can be converted into a binary format, and then the base64 encoding method is used for encoding to obtain an encoded file. The embodiment of the present application performs obfuscated encoding processing on the conversion string through the obfuscation array, which can make the original structure and content of the data difficult to identify and understand through complex transformations, and can effectively prevent attackers from obtaining data by guessing or brute force, thereby improving the confidentiality of data during storage and transmission and reducing the risk of data leakage.

[0131] See also Figure 6In step S501 of some embodiments, the random character insertion process is performed on the converted string according to the obfuscation array to obtain the obfuscated string, including the following steps:

[0132] Step S601, obtaining random characters, wherein the format of the random characters is the same as that of the converted character string;

[0133] Step S602, determining the index position according to the value of the obfuscated array;

[0134] Step S603: inserting the random character into the converted character string according to the index position to obtain an obfuscated character string.

[0135] In an embodiment of the present application, random characters are inserted into the conversion string according to the obfuscation array. The format of the random characters is the same as that of the conversion string. For example, if the format of the conversion string is a hexadecimal string, then the random character is a random character in the hexadecimal string. It is conceivable that when the random characters are inserted, the random characters inserted each time can be the same or different, and there is no limitation here. The obfuscation array is a binary array. Each value in the array represents whether to insert a random character. The insertion position is the index value of the obfuscation array. For example, the value of the obfuscation array is [1,0,1,0,1]. Then the value of the first index value is 1, indicating that the random character is inserted into the first position of the conversion string. The value of the second index value is 0, indicating that the second position of the conversion string is not inserted, and so on. The embodiment of the present application performs obfuscation processing on the conversion string through the obfuscation array, thereby improving the confidentiality of data during storage and transmission and reducing the risk of data leakage.

[0136] See also Figure 7 Another aspect of the embodiment of the present application provides a configuration file decoding method, the decoding method comprising the following steps:

[0137] Step S701, obtaining the encoding file and the obfuscation array;

[0138] Step S702, performing a process of removing obfuscated characters from the encoded file according to the obfuscation array to obtain a converted character string;

[0139] Step S703, converting and restoring the converted character string to obtain a byte array;

[0140] Step S704, performing deserialization processing on the byte array to obtain a configuration object.

[0141] In an embodiment of the present application, the server obtains an encoding file and an obfuscation array, which is generated when the configuration file is obfuscated and encoded. Then, the encoding file is subjected to obfuscated character removal processing according to the obfuscation array. For example, the encoding file is first decoded to obtain an obfuscated string, and the value in the obfuscated string is removed according to the value of the obfuscation array. For example, the value of the obfuscation array is [1,0,1,0,1], and the first character in the obfuscated string is removed to obtain a new string, and then the third character in the new string is removed to obtain an updated string, and then the fifth character in the updated string is removed to obtain a restored conversion string. Then, the conversion string is converted and restored. Since the XOR calculation process is used in the conversion process, the conversion string is reversed during the conversion and restoration, so that the second value in the reversed string is equal to the XOR value of the first value and the second value, and then the third value is equal to the XOR of the second value and the third value, and so on, until the last value is equal to the XOR of the second to last value and the last value, and finally the array is flipped to obtain the restored byte array. Finally, the byte array is deserialized to obtain the original configuration object, and the configuration object can be used. It should be noted that the obfuscation array is generated by the server according to a random algorithm, and the attacker cannot know the obfuscation rules and cannot obtain the information of the configuration file. In the embodiment of the present application, the decoding process does not need to use a password, nor does it need to store the password. The configuration object can be decoded by the obfuscation array to improve the security and confidentiality of the data.

[0142] The following is a detailed description of the embodiments of the present invention with reference to specific application examples:

[0143] The embodiment of the present application can be applied to the encoding and decoding scenarios of the configuration files of computer programs, wherein the encoding method of the embodiment of the present application can be deployed in an independent encoder software, and the decoding method can be deployed in a decoder module, which is in the server software code. First, the server developer prepares the configuration file, and the decoder module generates an obfuscation array according to the specified rules and configuration files. It should be noted that each server software uses different rules to generate an obfuscation array. The independent encoder encodes the configuration file according to the obfuscation array, and stores the encoded file in the server, which can be directly saved as a file or directly hard-coded in the server source code. After the server is started, the decoder module generates an obfuscation array and decodes the encoded configuration file into a configuration object. Specifically, the independent encoder software exists in a separate computer and is used to encode the configuration object; the decoder module is in the server code and is used to restore the configuration file to a configuration object. The embodiment of the present application runs the configuration file encoding method through the independent encoder software, and encodes the specified configuration file according to the obfuscation array generated by the decoder module to obtain an encoded file. The decoder module generates a random obfuscation array according to the configuration file, and then removes the obfuscated characters in the encoded file according to the random obfuscation array for the read-in encoded file, and then restores it to obtain a configuration object available to the software. The encoding method of the embodiment of the present application can effectively solve the security problem of the configuration file, improve the security of the configuration file without setting a key, and reduce the probability of the configuration file being cracked. In addition, the encoding cost of the embodiment of the present application is relatively small, and when performing decoding processing, the encoding speed is fast, and the configuration object can be accurately restored, which has the advantage of fast restoration speed.

[0144] See also Figure 8 The embodiment of the present application also provides a configuration file encoding device, which can implement the above configuration file encoding method, and the device includes:

[0145] The first module 801 is used to obtain a configuration file;

[0146] The second module 802 is used to perform object reading processing on the configuration file to generate a configuration object;

[0147] The third module 803 is used to serialize the configuration object to obtain a byte array;

[0148] The fourth module 804 is used to traverse and convert the byte array to obtain a converted string;

[0149] The fifth module 805 is used to generate an obfuscation array through the server according to the length of the converted string;

[0150] The sixth module 806 is used to perform obfuscation encoding processing on the conversion string according to the obfuscation array to obtain an encoded file.

[0151] It can be understood that the contents of the above-mentioned configuration file encoding method embodiment are all applicable to the configuration file encoding device embodiment, and the functions specifically implemented by the configuration file encoding device embodiment are the same as those of the above-mentioned configuration file encoding method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned configuration file encoding method embodiment.

[0152] See also Fig. 9 The embodiment of the present application also provides a configuration file decoding device, which can implement the above configuration file decoding method, and the device includes:

[0153] The seventh module 901 is used to obtain the encoding file and the obfuscation array;

[0154] An eighth module 902 is used to remove obfuscated characters from the encoded file according to the obfuscation array to obtain a converted character string;

[0155] The ninth module 903 is used to convert and restore the converted string to obtain a byte array;

[0156] The tenth module 904 is used to perform deserialization processing on the byte array to obtain a configuration object.

[0157] It can be understood that the contents of the above configuration file decoding method embodiment are all applicable to the configuration file decoding device embodiment, and the functions specifically implemented by the configuration file decoding device embodiment are the same as those of the above configuration file decoding method embodiment, and the beneficial effects achieved are also the same as those achieved by the above configuration file decoding method embodiment.

[0158] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above configuration file encoding or decoding method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0159] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0160] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0161] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.

[0162] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the configuration file encoding or decoding method of the embodiments of this application;

[0163] Input / output interface 1003, used to implement information input and output;

[0164] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);

[0165] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );

[0166] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0167] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned configuration file encoding or decoding method is implemented.

[0168] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0169] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0170] The embodiments of the present application provide a configuration file encoding method, decoding method, device and electronic device. The scheme obtains a configuration file, performs object reading processing on the configuration file, generates a configuration object, and serializes the configuration object to obtain a byte array. After the plaintext data is converted into a byte array, it can be further encrypted, thereby improving the security of the data. In addition, the scheme traverses and converts the byte array to obtain a conversion string, which can clear the serialization information and improve the security of the data. Furthermore, the scheme also generates an obfuscation array through a server according to the length of the conversion string, and performs obfuscated encoding processing on the conversion string according to the obfuscated array to obtain an encoded file. The obfuscation array generated by the server can make the original structure and content of the conversion string difficult to identify and understand, thereby improving the security of the data.

[0171] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0172] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0173] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0174] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0175] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to replace non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0176] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0177] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0178] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0180] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0181] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A configuration file encoding method, It is characterized in that The encoding method comprises the following steps: Get the configuration file; Performing object reading processing on the configuration file to generate a configuration object; Serializing the configuration object to obtain a byte array; Traversing and converting the byte array to obtain a converted string; Generate an obfuscation array through the server according to the length of the converted string; The conversion character string is subjected to obfuscation encoding processing according to the obfuscation array to obtain an encoded file.

2. The method according to claim 1, It is characterized in that The traversal and conversion processing of the byte array to obtain a conversion string includes the following steps: Get a first index value and a second index value; the first index value is an index value corresponding to the first value of the byte array, and the second index value is a value obtained by adding one to the first index value; Search the byte array according to the first index value and the second index value to obtain a first value and a second value; the first value is the byte value corresponding to the first index value, and the second value is the byte value corresponding to the second index value; Let the first value be equal to the XOR value of the first value and the second value; Add one to the first index value and the second index value, and return to searching the byte array according to the first index value and the second index value until the second index value is equal to the index value corresponding to the last value of the byte array, thereby obtaining a traversed array; Perform string conversion processing on the traversal array to obtain a converted string.

3. The method according to claim 1, It is characterized in that The generating of the obfuscation array by the server according to the length of the converted string comprises the following steps: Randomly select the static files on the server to obtain selected files; Performing random position reading processing on the selected file to obtain a read byte set; The read byte set is appended and merged according to the length of the converted string to obtain a confusion array.

4. The method according to claim 3, It is characterized in that The appending and merging processing is performed on the read byte set according to the length of the converted string to obtain a confusion array, comprising the following steps: Performing alternating hash processing on the bytes in the read byte set to obtain a hash array; Performing serial merging processing on the hash values ​​of the hash array to obtain a hash value array; The hash value array is extracted and processed according to the length of the converted string to obtain an obfuscated array.

5. The method according to claim 1, It is characterized in that The method of performing obfuscated encoding processing on the converted string according to the obfuscated array to obtain an encoded file comprises the following steps: Perform random character insertion processing on the conversion string according to the obfuscation array to obtain an obfuscated string; The obfuscated character string is encoded to obtain an encoded file.

6. The method according to claim 5, It is characterized in that The step of inserting random characters into the converted string according to the obfuscation array to obtain an obfuscated string comprises the following steps: Obtaining random characters, wherein the format of the random characters is the same as that of the converted character string; Determine the index position according to the value of the obfuscated array; The random characters are inserted into the converted character string according to the index position to obtain an obfuscated character string.

7. A configuration file decoding method, It is characterized in that The decoding method comprises the following steps: Get the encoded file and obfuscated array; According to the obfuscation array, the encoded file is subjected to obfuscated character removal processing to obtain a converted character string; Performing conversion and restoration processing on the conversion string to obtain a byte array; The byte array is deserialized to obtain a configuration object.

8. A configuration file encoding device, It is characterized in that The encoding device comprises: The first module is used to obtain the configuration file; The second module is used to perform object reading processing on the configuration file to generate a configuration object; The third module is used to serialize the configuration object to obtain a byte array; The fourth module is used to traverse and convert the byte array to obtain a converted string; A fifth module is used to generate an obfuscation array through a server according to the length of the conversion string; The sixth module is used to perform obfuscation encoding processing on the conversion string according to the obfuscation array to obtain an encoded file.

9. A configuration file encoding device, It is characterized in that The encoding device comprises: The seventh module is used to obtain the encoded file and obfuscation array; An eighth module is used to remove obfuscated characters from the encoded file according to the obfuscation array to obtain a converted character string; A ninth module is used to convert and restore the converted character string to obtain a byte array; The tenth module is used to perform deserialization processing on the byte array to obtain a configuration object.

10. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.