Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Script files are executable files written in accordance with a certain format. The script file may be written using a server and transmitted to the client through a network, thereby executing the script file in the client. In general, in order to ensure the transmission efficiency of script files, it is necessary to reduce the volume of script files.
In the traditional method, a script file is compressed through a compression algorithm, and a compressed script file is generated; and transmitting the compressed script file to the client.
However, during the transmission of the compressed script file, an attacker may intercept the compressed script file and tamper with the contents of the script file. Therefore, the conventional script file transmission method has a problem of insufficient security.
The file transmission method provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the client 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The server 104 acquires a target script file; the target script file is a script file in a character string format corresponding to the initial script file; the server 104 compresses the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string; the server 104 transmits the compressed script file to the client. The client 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, a file transfer method is provided, which is illustrated by using the method applied to the server 104 in fig. 1 as an example, and includes the following steps:
s220, acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file.
The script file may also be called dynamic script, and the script file is an executable file written according to a certain format. The initial script file is a script file directly written by the server, and the format of the initial script file is not a character string format. The target script file refers to a script file in a character string format corresponding to the initial script file. Script files in string format may be transmitted in text form through an interface.
Alternatively, the server 104 may directly obtain the target script file in the character string format corresponding to the initial script file. Alternatively, the server 104 may first obtain the initial script file. Then, the server 104 may perform encoding processing on the initial script file by using a preset encoding method, so as to generate a target script file in a character string format corresponding to the initial script file. The preset encoding method may include, but is not limited to, a base64 encoding method.
S240, compressing the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string.
Alternatively, the server 104 may compress the target script file using a preset character substitution rule, and generate a compressed script file. For example, assuming that the preset character replacement rule includes a first preset character replacement rule and a second preset character replacement rule, the server 104 may alternatively compress the target script file using only the first preset character replacement rule to generate a compressed script file. Alternatively, the server 104 may compress the target script file by using only the second preset character substitution rule, and generate a compressed script file. Alternatively, the server 104 may compress the target script file by using a first preset character replacement rule, to generate a script file after first compression; then, the server 104 may compress the script file after the first compression again by adopting the second preset character replacement rule, so as to generate a compressed script file. Of course, the number of rules included in the preset character substitution rule and the sequence of the usage rules are not limited in this embodiment. The preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format, and the character length of the target type character string is smaller than that of the preset type character string.
And S260, transmitting the compressed script file to the client.
Alternatively, the server 104 may transmit the compressed script file to the client, so that the compressed script file may be decompressed in the client and the decompressed script file may be executed in the client. The compressed script file refers to a script file obtained by compressing the target script file by adopting a preset character replacement rule.
In the file transmission method, a target script file is acquired; the target script file is a script file in a character string format corresponding to the initial script file; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string; and transmitting the compressed script file to the client. Because the preset character replacement rule in the application includes the mapping relation between the preset type character string in the script file in the custom character string format and the custom target type character string, the target script file is compressed by adopting the custom preset character replacement rule, the compressed script file can be generated, and the compressed script file includes the custom target type character string. Therefore, in the process of transmitting the compressed script file to the client, even if an attacker can intercept the compressed script file, the attacker cannot restore the self-defined target type character string in the compressed script file into the target script file. Therefore, an attacker cannot acquire and tamper with the target script file before compression, so that the security of the script file transmission process can be ensured.
In the above embodiment, the target script file is compressed by adopting the preset character replacement rule, so as to generate a compressed script file, and a specific method thereof is described below. In one embodiment, as shown in fig. 3, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format, and S240 includes:
s320, obtaining the target universal character string in the target script file from the target script file.
Optionally, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format. Then, the character length of the first target type character string is smaller than the character length of the preset general character string. The server 104 may obtain, in advance, a preset universal string in the script file in the string format, a first target type string corresponding to the preset universal string, and a first mapping relationship between the preset universal string and the first target type string in the script file in the string format. Then, the server 104 may obtain the target universal character string in the target script file from the target script file according to the preset universal character string in the script file in the character string format.
For example, assuming that the preset universal string in the script file in the string format includes UEsDBBQACAgIA, UAAQATUVUQS1JTkYv, etc., the server 104 may use the preset universal string to search the target script file, and generate a search result. If the search result indicates that the target script file contains UAAQATAUUQS 1JTkYv, determining the UAAQATAUUQS 1JTkYv as a target universal character string in the target script file.
S340, obtaining a first target type character string corresponding to the target general character string from the first mapping relation.
Alternatively, according to the target universal string in the target script file, the server 104 may obtain a first target type string corresponding to the target universal string from the first mapping relationship. For example, it is assumed that the preset universal character string in the script file in the character string format includes UAAQATUVUQS1JTkYv, and the first target type character string corresponding to UAAQATUVUQS1JTkYv in the first mapping relationship is @2. When the server 104 determines that the target universal character string in the target script file is UAAQATUVUQS1JTkYv, the server 104 may obtain a first target type character string corresponding to UAAQATUVUQS1JTkYv as @2 from the first mapping relationship.
S360, replacing the target universal character string with the first target type character string corresponding to the target universal character string, and generating the compressed script file.
Alternatively, after the first target type string corresponding to the target general string is obtained, the server 104 may replace the target general string with the first target type string corresponding to the target general string, and generate the compressed script file. For example, assume that the target script file includes ASQAAAAAUAAQATUVUQS1JTkYvASQAA in a character string format, and that the server 104 has determined that the target general character string included in the target script file is UAAQATUVUQS1JTkYv, and has determined that the first target type character string corresponding to UAAQATUVUQS1JTkYv is @2. Then, the server 104 replaces UAAQATUVUQS1JTkYv in asqaaauaaqatuvuqs 1JTkYv with @2, resulting in the compressed script file being asqaaaaa@2asqaa.
In this embodiment, the target universal character string in the target script file is obtained from the target script file, so that the replaceable target universal character string with a longer character length can be determined. Therefore, the first target type character string corresponding to the target general character string can be obtained from the first mapping relation, and the first target type character string with shorter character length for replacement can be determined. Then, the target universal character string is replaced by the first target type character string corresponding to the target universal character string, so that the compressed script file can be generated, and the volume of the target script file can be reduced. In the process of compressing the target script file based on the customized first mapping relationship, because the first target type character strings are customized in replacement, an attacker cannot acquire the first target type character strings and the customized first mapping relationship. Furthermore, an attacker cannot acquire and tamper the target script file before compression, so that the safety of the target script file can be ensured, and the purposes of preventing tampering and counterfeiting the target script file are achieved.
In the above embodiment, the target script file is compressed by adopting the preset character replacement rule, so as to generate a compressed script file, and a specific method thereof is described below. In one embodiment, as shown in fig. 4, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and a second target type string in the script file in the string format, and S240 includes:
s420, acquiring a target continuous character string in the target script file from the target script file; the target continuous string includes at least three continuous and identical target characters.
Optionally, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and the second target type string in the script file in the string format. Then, the character length of the second target type character string is smaller than the character length of the preset continuous character string. The server 104 may obtain, in advance, a preset continuous string in the script file in the string format, a second target type string corresponding to the preset continuous string, and a second mapping relationship between the preset continuous string and the second target type string in the script file in the string format. Then, the server 104 may obtain the target continuous character string in the target script file from the target script file according to the preset continuous character string in the script file in the character string format. Wherein the target continuous string comprises at least three continuous and identical target characters.
For example, assuming that the preset continuous character string in the script file in the character string format includes AAAAAA, BBBBBBBBBBBBB, etc., the server 104 may retrieve the target script file using the preset continuous character string, and generate a retrieval result. And if the search result indicates that the target script file contains AAAAAA, determining the AAAAAA as a target continuous character string in the target script file.
S440, obtaining a second target type character string corresponding to the target continuous character string from the second mapping relation.
Alternatively, according to the target continuous string in the target script file, the server 104 may obtain a second target type string corresponding to the target continuous string from the second mapping relationship. For example, it is assumed that the preset continuous character string in the script file in the character string format includes AAAAAA, and the second target type character string corresponding to AAAAAA in the second mapping relationship is a×6. When the server 104 determines that the target continuous string in the target script file is AAAAAA, the server 104 may obtain, from the second mapping relationship, that a second target type string corresponding to aaaaaaaa is a×6.
S460, replacing the target continuous character string with a character string of a second target type corresponding to the target continuous character string, and generating a compressed script file.
Alternatively, after the second target type string corresponding to the target continuous string is obtained, the server 104 may replace the target continuous string with the second target type string corresponding to the target continuous string, and generate the compressed script file. For example, assume that the target script file includes asqaaaaa@2asqaa in a string format, and that server 104 has determined that the target continuous string included in the target script file is AAAAA, and has determined that the second target type string corresponding to AAAAA is a×5. Then the server 104 replaces AAAAA in asqaaaaa@2asqaa with a×5, resulting in a compressed script file of asqa×5@2asqaa.
In this embodiment, the target continuous character string in the target script file is obtained from the target script file, so that the replaceable target continuous character string with a longer character length can be determined. Therefore, the second target type character string corresponding to the target continuous character string can be obtained from the second mapping relation, and the second target type character string with shorter character length for replacement can be determined. Then, the target continuous character string is replaced by the character string of the second target type corresponding to the target continuous character string, so that the compressed script file can be generated, and the volume of the target script file can be reduced. In the process of compressing the target script file based on the customized second mapping relationship, because the second target type character strings are replaced by the customized second target type character strings, an attacker cannot acquire the second target type character strings and the customized second mapping relationship. Furthermore, an attacker cannot acquire and tamper the target script file before compression, so that the safety of the target script file can be ensured, and the purposes of preventing tampering and counterfeiting the target script file are achieved.
In the above embodiment, the replacing the target continuous character string with the second target type character string corresponding to the target continuous character string is involved, and the compressed script file is generated, and a specific method thereof is described below. In one embodiment, S460 includes:
if the number of the target continuous character strings is smaller than the preset threshold, replacing the target continuous character strings with the second target type character strings generated based on the target characters and the number of the target characters, and generating the compressed script file.
If the number of the target continuous character strings is larger than or equal to a preset threshold value, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and preset ending characters, and generating a compressed script file.
Alternatively, if the number of the target continuous strings is smaller than the preset threshold, the server 104 may generate the second target type character based on the target character and the number of the target characters, and replace the target continuous strings with the second target type character string to generate the compressed script file. If the number of the target continuous strings is greater than or equal to the preset threshold, the server 104 may generate a second target type string based on the target characters, the number of the target characters, and the preset end characters, and replace the target continuous strings with the second target type string to generate the compressed script file. The preset threshold may be set according to the number of the target continuous strings, which is not limited in the embodiment of the present application.
Illustratively, assume that the preset threshold is 10 and the target character is a. If the target continuous character string is AAAA, the number of the target continuous character strings AAAA is greater than 2 and less than 10, and then the server 104 may determine that the number of the target characters a is 4, so that the server 104 may generate the second target type character a×4 based on the number of the target characters a and the target characters a. After that, the server 104 may replace AAAA with a×4, and generate a compressed script file. If the number of target continuous strings is AAAAAAAAAAAAAAAA, the number of target continuous strings AAAAAAAAAAAAAAAA is greater than 10, the server 104 may determine that the number of target characters a is 16, so that the server 104 may generate the second type character a 16 based on the number of target characters a and the preset end character. Then, the server 104 may replace AAAAAAAAAAAAAAAA with a×16&, and generate a compressed script file.
In this embodiment, if the number of the target continuous strings is smaller than the preset threshold, replacing the target continuous strings with the second target type strings generated based on the target characters and the number of the target characters, and generating a compressed script file; if the number of the target continuous character strings is larger than or equal to a preset threshold value, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and preset ending characters, and generating a compressed script file. Different second target type character strings are set according to different numbers of the target continuous character strings, and the second target type character strings corresponding to the different target continuous character strings can be accurately determined.
In the above embodiment, the preset character replacement rule includes the first mapping relationship between the preset universal character string and the first target type character string in the script file in the character string format, and a specific method for generating the first mapping relationship is described below. In one embodiment, as shown in fig. 5, the file transfer method further includes:
s520, acquiring a plurality of history script files; the history script file is a script file in a character string format.
Alternatively, the server 104 may directly obtain a plurality of history script files. Alternatively, the server 104 may first obtain a plurality of historical initial script files. Then, for each history initial script file in the plurality of history initial script files, the server 104 may perform encoding processing on the history initial script file by using a preset encoding method, so as to generate a history script file in a character string format corresponding to each history initial script file, thereby obtaining a plurality of history script files. The history script file is a script file in a character string format, and the preset encoding method may include, but is not limited to, a base64 encoding method.
S540, determining a preset universal character string from a plurality of history script files; the preset universal character string is a universal character string in a plurality of history script files.
Alternatively, the server 104 may compare the strings in the plurality of history script files to obtain a comparison result. The comparison result comprises a plurality of universal character strings in the history script files. Then, the server 104 may determine, according to the comparison result, a general character string in the plurality of history script files from the plurality of history script files, and use the general character string in the plurality of history script files as a preset general character string. The preset universal character string is a universal character string in a plurality of history script files.
S560, generating a first target type character string corresponding to the preset universal character string according to each preset universal character string.
S580, a first mapping relation is generated according to the preset universal character string and the first target type character string corresponding to the preset universal character string.
Alternatively, for each preset universal string, the server 104 may set a different first target type string for each preset universal string in a customized manner, so as to generate a first target type string corresponding to the preset universal string. Then, the server 104 may generate a correspondence between the preset universal string and the first target type string corresponding to the preset universal string according to the preset universal string and the first target type string corresponding to the preset universal string, so as to generate a first mapping relationship based on the correspondence.
For example, assume that the preset general character string includes UEsDBBQACAgIA, UAAQATUVUQS1JTkYv, 7l aaaaaaaaaaaaaaaaa, etc., and the first target type character string corresponding to uesbdbqacagia is set to @1, the first target type character string corresponding to UAAQATUVUQS1 jtkkyv is set to @2, and the first target type character string corresponding to 7l aaaaaaaaaaaaaaa is set to @3. Then, the first mapping relationship includes a correspondence between uesbbqacagia and @1, a correspondence between UAAQATUVUQS1JTkYv and @2, and a correspondence between 7l aaaaaaaaaaaaaaa and an symbol @3.
Illustratively, the first mapping may be in the form of a compression table, which may include, but is not limited to:
map.put("@1","UEsDBBQACAgIA");
map.put("@2","UAAQATUVUQS1JTkYv");
map.put("@3","7lAAAAAAAAAAAAAAAAA");
map.put("@4","7lAAAAAAAgAAAAAAAAA");
map.put("@5","PAAAAY29tL2FyY2gvcGF0Y2gvAwBQSwcIAAAAAAIAAAAAAA");
map.put("@6","ygAA803My0xLLS7RDUstKs7Mz7NSMNQz4OVySa3Q9clPTiwBCyXnJB YXpxbrpaRW8HI5F6UmlqSm6DpVWimkVACVGxrzcvFyAQBQSwcIgFFTUEcAAABJ");
map.put("@7","LAAAAY2xhc3Nlcy5kZXiNl");
map.put("@8","AAUEsBAhQAFAAICAgA");
map.put("@9","L1BLAQIUABQACAgIAB");
map.put("@a","uUIBRU1BHAAAASQAAABQABAAAAAAAAAAAAAAAAAAAAE1FVEEtSU5GL01BTklGRVNULk1G");
map.put("@b","AwBQSwcIAAAAAAIAAAAA");
map.put("@c","TUFOSUZFU1QuTUb");
in this embodiment, a plurality of history script files in a character string format are obtained, and a preset universal character string is determined from the plurality of history script files, so that the preset universal character string which is universal in the plurality of history script files can be determined more accurately. Aiming at each preset universal character string, a first target type character string corresponding to the preset universal character string is generated, and the first target type character string with shorter character length corresponding to each preset universal character string can be accurately determined. Therefore, the first mapping relation can be accurately generated according to the accurate preset universal character string and the accurate first target type character string corresponding to the accurate preset universal character string.
In one embodiment, as shown in fig. 6, a file transfer method is further provided, which is illustrated by using the method applied to the client 102 in fig. 1 as an example, and includes the following steps:
s620, receiving the compressed script file.
Alternatively, after compressing the target script file by the server 104, generating a compressed script file, the server 104 may transmit the compressed script file to the client 102. Thus, client 102 may receive the compressed script file sent by server 104. The compressed script file refers to a script file obtained by compressing the target script file by adopting a preset character replacement rule.
S640, decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string.
Alternatively, the client 102 may decompress the compressed script file using a preset character replacement rule, and generate a decompressed script file. For example, assuming that the preset character replacement rule includes a first preset character replacement rule and a second preset character replacement rule, optionally, the client 102 may decompress the compressed script file only by using the first preset character replacement rule to generate a decompressed script file, or the client 102 may decompress the compressed script file only by using the second preset character replacement rule to generate a decompressed script file. Alternatively, the client 102 may decompress the compressed script file by using a second preset character replacement rule, to generate a script file after first decompression; then, the client 102 may decompress the first decompressed script file by using the first preset character substitution rule, to generate a decompressed script file. Of course, the number of rules included in the preset character substitution rule and the sequence of the usage rules are not limited in this embodiment. The preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format, and the character length of the target type character string is smaller than that of the preset type character string.
First, the client 102 may retrieve the compressed script file to determine the compressed script file. Thus, the client 102 may determine the second target type string in the compressed script file according to the x in the compressed script file. Then, the client 102 may reversely restore the second target type string in the compressed script file to the target continuous string according to the second mapping relationship, thereby generating the script file decompressed for the first time. Second, the client 102 may retrieve @ in the first decompressed script file, thereby determining @ in the first decompressed script file. Thus, the client 102 may determine, according to @ in the first decompressed script file, a first target type string in the first decompressed script file. Then, the client 102 may reversely restore the first target type string in the first decompressed script file to the target universal string according to the first mapping relationship, thereby generating the decompressed script file.
S660, decoding the decompressed script file to generate an initial script file.
Alternatively, since the decompressed script file is a script file in a character string format, the client 102 may decode the decompressed script file to generate an initial script file. The initial script file is a script file directly written by the server, and the format of the initial script file is not a character string format.
In this embodiment, a compressed script file is received; decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string; decoding the decompressed script file to generate an initial script file. Because the preset character replacement rule in the application includes the mapping relation between the preset type character string and the self-defined target type character string in the script file in the self-defined character string format, the compressed script file is decompressed by adopting the self-defined preset character replacement rule, the decompressed script file can be generated, and the decompressed script file can be generated only based on the self-defined target type character string. Therefore, an attacker cannot decompress the compressed script file based on the custom target type character string, so that the attacker cannot acquire and tamper with the decompressed script file, and the security of the script file transmission process can be ensured.
In order to make the scheme of the present application more clear, the file transfer method described above is described in an alternative embodiment below. In an alternative embodiment, as shown in fig. 7, a file transfer method is provided, applied to the server 104, and includes:
s702, acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file;
s704, acquiring a plurality of history script files; the history script file is a script file in a character string format;
s706, determining a preset universal character string from a plurality of history script files; presetting universal character strings as universal character strings in a plurality of history script files;
s708, generating a first target type character string corresponding to the preset universal character string according to each preset universal character string;
s710, generating a first mapping relation according to a preset universal character string and a first target type character string corresponding to the preset universal character string;
s712, if the preset type character string comprises a preset universal character string, the preset character replacement rule comprises a first mapping relation between the preset universal character string and the first target type character string in the script file in the character string format, and the target universal character string in the target script file is obtained from the target script file;
S714, acquiring a first target type character string corresponding to the target general character string from the first mapping relation;
s716, replacing the target universal character string with a first target type character string corresponding to the target universal character string, and generating a script file after first compression;
s718, if the preset type character string comprises a preset continuous character string, the preset character replacement rule comprises a second mapping relation between the preset continuous character string and a second target type character string in the script file in a character string format, and the target continuous character string in the script file after the first compression is obtained from the script file after the first compression; the target continuous character string comprises at least three continuous and identical target characters;
s720, acquiring a second target type character string corresponding to the target continuous character string from the second mapping relation;
s722, if the number of the target continuous character strings is smaller than a preset threshold, replacing the target continuous character strings with second target type character strings generated based on the target characters and the number of the target characters, and generating a compressed script file;
s724, if the number of the target continuous character strings is greater than or equal to a preset threshold, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and the preset end characters, and generating a compressed script file;
S726, transmitting the compressed script file to the client.
In the file transmission method, because the preset character replacement rule in the application includes the mapping relation between the preset type character string and the preset target type character string in the script file in the self-defined character string format, the target script file is compressed (i.e. long characters are replaced by short characters) by adopting the self-defined preset character replacement rule (including the self-defined compression table and the self-defined target continuous character string replacement rule), so that the compressed script file can be generated, and the volume of the target script file can be reduced. And the compressed script file comprises a custom target type character string. Therefore, in the process of transmitting the compressed and confusing script file to the client, even if an attacker can intercept the compressed script file, the attacker cannot acquire the customized compression table and the customized target continuous character string replacement rule, so that the attacker cannot restore the customized target type character string in the compressed script file into the target script file. Therefore, an attacker cannot view and tamper with the target script file before compression, so that the security of the script file transmission process can be ensured.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a file transmission device for realizing the above related file transmission method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the file transmission device provided below may refer to the limitation of the file transmission method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 8, there is provided a file transfer apparatus 800 comprising: an acquisition module 820, a compression module 840 and a transmission module 860, wherein:
an acquisition module 820 for acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file.
The compression module 840 is configured to compress the target script file by using a preset character replacement rule, and generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string.
And the transmission module 860 is used for transmitting the compressed script file to the client.
In one embodiment, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format; the compression module 840 includes:
a target general character string obtaining unit for obtaining a target general character string in the target script file from the target script file;
The first target type character string acquisition unit is used for acquiring a first target type character string corresponding to the target general character string from the first mapping relation;
and the first compression unit is used for replacing the target general character string with a first target type character string corresponding to the target general character string and generating a compressed script file.
In one embodiment, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and a second target type string in the script file in the string format; the compression module 840 includes:
a target continuous character string obtaining unit for obtaining a target continuous character string in the target script file from the target script file; the target continuous character string comprises at least three continuous and identical target characters;
the second target type character string obtaining unit is used for obtaining a second target type character string corresponding to the target continuous character string from the second mapping relation;
and the second compression unit is used for replacing the target continuous character string with a second target type character string corresponding to the target continuous character string to generate a compressed script file.
In one embodiment, the second compression unit includes:
a first replacing subunit, configured to replace the target continuous character string with a second target type character string generated based on the target character and the number of the target characters, and generate a compressed script file when the number of the target continuous character strings is less than a preset threshold;
and the second replacing subunit is used for replacing the target continuous character strings with the second target type character strings generated based on the target characters, the number of the target characters and the preset ending characters under the condition that the number of the target continuous character strings is larger than or equal to a preset threshold value, and generating the compressed script file.
In one embodiment, the file transfer device 800 further includes:
the history script file acquisition module is used for acquiring a plurality of history script files; the history script file is a script file in a character string format;
the preset universal character string determining module is used for determining preset universal character strings from a plurality of history script files; presetting universal character strings as universal character strings in a plurality of history script files;
the first target type character string generation module is used for generating a first target type character string corresponding to each preset universal character string;
The first mapping relation generation module is used for generating a first mapping relation according to a preset general character string and a first target type character string corresponding to the preset general character string.
In one embodiment, there is also provided a file transfer apparatus 800, including:
the receiving module is used for receiving the compressed script file;
the decompression module is used for decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
and the initial script file generation module is used for decoding the decompressed script file to generate an initial script file.
The respective modules in the above-described file transfer device may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 9. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing file transfer data. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a file transfer method.
It will be appreciated by persons skilled in the art that the architecture shown in fig. 9 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements are applicable, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory having a computer program stored therein for application to a server, and a processor that when executing the computer program performs the steps of:
acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file;
compressing the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
and transmitting the compressed script file to the client.
In one embodiment, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the processor executes the computer program:
Acquiring a target universal character string in a target script file from the target script file;
acquiring a first target type character string corresponding to the target general character string from the first mapping relation;
and replacing the target universal character string with the first target type character string corresponding to the target universal character string, and generating the compressed script file.
In one embodiment, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and a second target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the processor executes the computer program:
acquiring a target continuous character string in a target script file from the target script file; the target continuous character string comprises at least three continuous and identical target characters;
acquiring a second target type character string corresponding to the target continuous character string from the second mapping relation;
and replacing the target continuous character string with a second target type character string corresponding to the target continuous character string, and generating the compressed script file.
In one embodiment, the target continuous character string is replaced by a second target type character string corresponding to the target continuous character string, a compressed script file is generated, and the following steps are further implemented when the processor executes the computer program:
if the number of the target continuous character strings is smaller than a preset threshold, replacing the target continuous character strings with second target type character strings generated based on the target characters and the number of the target characters, and generating a compressed script file;
if the number of the target continuous character strings is larger than or equal to a preset threshold value, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and preset ending characters, and generating a compressed script file.
In one embodiment, the processor when executing the computer program further performs the steps of:
acquiring a plurality of history script files; the history script file is a script file in a character string format;
determining a preset universal character string from a plurality of history script files; presetting universal character strings as universal character strings in a plurality of history script files;
generating a first target type character string corresponding to the preset universal character string aiming at each preset universal character string;
And generating a first mapping relation according to the preset universal character string and the first target type character string corresponding to the preset universal character string.
In one embodiment, a computer device is provided, including a memory and a processor, where the memory stores a computer program, and the computer program is applied to a client, and when executed by the processor, the processor further implements the steps of:
receiving the compressed script file;
decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
decoding the decompressed script file to generate an initial script file.
In one embodiment, a computer readable storage medium is provided, having stored thereon a computer program for application to a server, the computer program when executed by a processor performing the steps of:
acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file;
Compressing the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
and transmitting the compressed script file to the client.
In one embodiment, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the computer program is executed by the processor:
acquiring a target universal character string in a target script file from the target script file;
acquiring a first target type character string corresponding to the target general character string from the first mapping relation;
and replacing the target universal character string with the first target type character string corresponding to the target universal character string, and generating the compressed script file.
In one embodiment, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and a second target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the computer program is executed by the processor:
acquiring a target continuous character string in a target script file from the target script file; the target continuous character string comprises at least three continuous and identical target characters;
acquiring a second target type character string corresponding to the target continuous character string from the second mapping relation;
and replacing the target continuous character string with a second target type character string corresponding to the target continuous character string, and generating the compressed script file.
In one embodiment, the target continuous character string is replaced by a second target type character string corresponding to the target continuous character string, a compressed script file is generated, and the computer program when executed by the processor further realizes the following steps:
if the number of the target continuous character strings is smaller than a preset threshold, replacing the target continuous character strings with second target type character strings generated based on the target characters and the number of the target characters, and generating a compressed script file;
If the number of the target continuous character strings is larger than or equal to a preset threshold value, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and preset ending characters, and generating a compressed script file.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a plurality of history script files; the history script file is a script file in a character string format;
determining a preset universal character string from a plurality of history script files; presetting universal character strings as universal character strings in a plurality of history script files;
generating a first target type character string corresponding to the preset universal character string aiming at each preset universal character string;
and generating a first mapping relation according to the preset universal character string and the first target type character string corresponding to the preset universal character string.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, for application to a client, the computer program when executed by a processor further implementing the steps of:
receiving the compressed script file;
decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
Decoding the decompressed script file to generate an initial script file.
In one embodiment, a computer program product is provided, comprising a computer program for application to a server, which computer program, when executed by a processor, performs the steps of:
acquiring a target script file; the target script file is a script file in a character string format corresponding to the initial script file;
compressing the target script file by adopting a preset character replacement rule to generate a compressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
and transmitting the compressed script file to the client.
In one embodiment, if the preset type string includes a preset universal string, the preset character replacement rule includes a first mapping relationship between the preset universal string and the first target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the computer program is executed by the processor:
Acquiring a target universal character string in a target script file from the target script file;
acquiring a first target type character string corresponding to the target general character string from the first mapping relation;
and replacing the target universal character string with the first target type character string corresponding to the target universal character string, and generating the compressed script file.
In one embodiment, if the preset type string includes a preset continuous string, the preset character replacement rule includes a second mapping relationship between the preset continuous string and a second target type string in the script file in the string format; compressing the target script file by adopting a preset character replacement rule to generate a compressed script file, and realizing the following steps when the computer program is executed by the processor:
acquiring a target continuous character string in a target script file from the target script file; the target continuous character string comprises at least three continuous and identical target characters;
acquiring a second target type character string corresponding to the target continuous character string from the second mapping relation;
and replacing the target continuous character string with a second target type character string corresponding to the target continuous character string, and generating the compressed script file.
In one embodiment, the target continuous character string is replaced by a second target type character string corresponding to the target continuous character string, a compressed script file is generated, and the computer program when executed by the processor further realizes the following steps:
if the number of the target continuous character strings is smaller than a preset threshold, replacing the target continuous character strings with second target type character strings generated based on the target characters and the number of the target characters, and generating a compressed script file;
if the number of the target continuous character strings is larger than or equal to a preset threshold value, replacing the target continuous character strings with character strings of a second target type generated based on the target characters, the number of the target characters and preset ending characters, and generating a compressed script file.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring a plurality of history script files; the history script file is a script file in a character string format;
determining a preset universal character string from a plurality of history script files; presetting universal character strings as universal character strings in a plurality of history script files;
generating a first target type character string corresponding to the preset universal character string aiming at each preset universal character string;
And generating a first mapping relation according to the preset universal character string and the first target type character string corresponding to the preset universal character string.
In one embodiment, a computer program product is provided, comprising a computer program for application to a client, the computer program when executed by a processor further implementing the steps of:
receiving the compressed script file;
decompressing the compressed script file by adopting a preset character replacement rule to generate a decompressed script file; the preset character replacement rule comprises a mapping relation between a preset type character string and a target type character string in a script file in a character string format; the character length of the target type character string is smaller than the character length of the preset type character string;
decoding the decompressed script file to generate an initial script file.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.