Subtitle file encryption and decryption method, system, storage medium and electronic device
By generating a character comparison table and sequential marking collection, the subtitle file is encrypted, which solves the problem that subtitle streams are easily stolen and realizes effective protection of subtitle files.
Patent Information
- Application Number
- CN202111431014.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-11-29
AI Technical Summary
Existing DRM systems cannot effectively protect independent subtitle streams, resulting in subtitle streams being easily stolen by illegal users.
By generating a character comparison table, the characters in the subtitle file are converted into character representation data, and the order marking set is generated according to the preset sorting to form an encrypted subtitle file, which increases the difficulty of cracking.
Effectively prevent subtitle streams from being stolen by illegal users, improve the protection strength of subtitle files, and increase the cracking cost.
Smart Images

Figure CN114091081B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of subtitle security technology, and in particular to a subtitle file encryption and decryption method, system, storage medium and electronic equipment. Background Art
[0002] As people's awareness of digital copyright increases, the DRM (Digital Rights Management) system came into being. The DRM system can effectively protect the copyright of digital video content being played, prevent digital video content from being illegally copied, reproduced and disseminated, and make it impossible for illegal or unauthorized users to play video programs normally.
[0003] However, when playing videos with subtitles, the video stream can usually be protected by the DRM system, but the independent subtitle stream cannot be protected, and most independent subtitle streams are transmitted in plain text. Therefore, how to prevent the independent subtitle stream from being stolen by illegal or unauthorized users has become a problem that needs to be solved urgently. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a subtitle file encryption and decryption method, system, storage medium and electronic device, which can solve the problem that the subtitle stream is stolen due to the transmission of subtitles in plain text. The specific technical solution is as follows:
[0005] The present invention provides a subtitle file encryption method, comprising:
[0006] Acquire a subtitle file to be encrypted; the subtitle file includes multiple groups of sentences with playback period marks; the sentences include one or more characters;
[0007] According to the character comparison table, character representation data corresponding to the characters in the sentence are obtained; the character representation data is used to represent the characters by data different from the characters, the character comparison table is used to characterize the correspondence between the characters and the character representation data, different characters correspond to different character representation data, each character representation data in the character comparison table has a sequence mark set according to a preset sorting order, and different character representation data have different sequence marks;
[0008] Replacing characters in the sentence with character representation data corresponding to the characters, and representing the characters in the sentence with sequence marks possessed by the character representation data corresponding to the characters, and setting the arrangement position of each sequence mark according to the arrangement position of the characters in the sentence, to obtain a sequence mark set corresponding to the sentence;
[0009] According to the playing time period of the sentences corresponding to the sequence mark set, the sequence mark set is spliced into an encrypted subtitle file.
[0010] Optionally, the character comparison table is generated by:
[0011] Deduplication processing is performed on the characters in the subtitle file to be encrypted to obtain deduplicated characters; character representation data is selected from the first character representation data set to obtain selected character representation data; the selected character representation data is different from the deduplicated characters, and the number of the selected character representation data is not less than the number of the deduplicated characters; the deduplicated characters and the selected character representation data are matched, so that each of the deduplicated characters corresponds to at least one of the selected character representation data and the character representation data corresponding to different characters are different, and a character comparison table is generated.
[0012] Optionally, the character comparison table is generated by at least one of method 1 and method 2:
[0013] The first method specifically includes: obtaining a commonly used character set and a second character representation data set; the number of character representation data in the second character representation data set is not less than the number of symbols in the commonly used symbol set; selecting character representation data from the second character representation data set to correspond to characters in the commonly used character set, so that each character in the commonly used character set corresponds to at least one character representation data in the second character representation data set and different characters correspond to different character representation data, and generating a character comparison table;
[0014] The second method specifically includes: obtaining a correspondence relationship file; the correspondence relationship file includes a plurality of groups of correspondence relationships between characters and character representation data, the characters and character representation data in each group of the correspondence relationships are different, and the character representation data in different correspondence relationships are different; selecting the correspondence relationship between the characters and character representation data that matches the characters in the subtitle file to be encrypted from the correspondence relationship file to generate a character comparison table.
[0015] Optionally, the preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the sentence, or the preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the character comparison table.
[0016] Optionally, the method for generating the character representation data specifically includes:
[0017] Get character image;
[0018] generating image coding data of the character image;
[0019] The image encoding data is used as character representation data corresponding to the characters in the character image.
[0020] The present invention also provides a subtitle file encryption system, comprising:
[0021] A first file acquisition module is used to acquire a subtitle file to be encrypted; the subtitle file includes a plurality of sentences with playback period marks; the sentences include one or more characters;
[0022] A character representation module, used for obtaining character representation data corresponding to the characters in the sentence according to a character comparison table; the character representation data is used for representing the characters by data different from the characters, the character comparison table is used for representing the correspondence between the characters and the character representation data, different characters correspond to different character representation data, each character representation data in the character comparison table has a sequence mark set according to a preset sorting order, and different character representation data have different sequence marks;
[0023] A sequence mark set generation module, used for replacing characters in the sentence with character representation data corresponding to the characters, and representing the characters in the sentence with sequence marks possessed by the character representation data corresponding to the characters, and setting the arrangement position of each sequence mark according to the arrangement position of the characters in the sentence, to obtain a sequence mark set corresponding to the sentence;
[0024] The encryption module is used to splice the sequence mark set into an encrypted subtitle file according to the playing time period of the sentence corresponding to the sequence mark set.
[0025] The present invention also provides a subtitle file decryption method, comprising:
[0026] Acquire a subtitle file to be decrypted; the subtitle file to be decrypted includes a plurality of sequence mark sets spliced in the order of the playback time periods; the sequence mark set includes a plurality of sequence marks having an arrangement order, and the arrangement order of the sequence marks represents the arrangement order of characters in the sentences of the subtitle file;
[0027] Obtaining a sequence mark set corresponding to the playback period in the subtitle file to be decrypted, to obtain a sequence mark set;
[0028] The sequential mark set is represented by character representation data having sequential marks set in a preset order, and the arrangement position of each character representation data is set according to the arrangement position of the sequential marks in the sequential mark set, so as to obtain a character representation data set corresponding to the sequential mark set; the character representation data is used to represent the character by data different from the character;
[0029] Performing character conversion on the character representation data in the character representation data set according to the character comparison table to obtain characters corresponding to the playback time period; the character comparison table is used to represent the correspondence between characters and character representation data, and different characters correspond to different character representation data;
[0030] The characters are sorted according to the character representation data arrangement order in the character representation data set to obtain a sentence corresponding to the playback time period.
[0031] The present invention also provides a subtitle file decryption system, comprising:
[0032] A second file acquisition module is used to acquire a subtitle file to be decrypted; the subtitle file to be decrypted includes a plurality of sequence mark sets spliced in the order of the playback time periods; the sequence mark set includes a plurality of sequence marks having an arrangement order, and the arrangement order of the sequence marks represents the arrangement order of characters in the sentences of the subtitle file;
[0033] A set acquisition module, used to acquire a sequence mark set corresponding to a playback period in the subtitle file to be decrypted, to obtain a sequence mark set;
[0034] a character representation data set generation module, used to represent the sequential mark set with character representation data having sequential marks set in a preset order, and to set the arrangement position of each character representation data according to the arrangement position of the sequential marks in the sequential mark set, so as to obtain a character representation data set corresponding to the sequential mark set; the character representation data is used to represent the character by data different from the character;
[0035] A character conversion module, used for performing character conversion on the character representation data in the character representation data set according to a character comparison table to obtain characters corresponding to the play time period; the character comparison table is used to represent the correspondence between characters and character representation data, and different characters correspond to different character representation data;
[0036] The decryption module is used to sort the characters according to the character representation data arrangement order in the character representation data set to obtain a sentence corresponding to the playback time period.
[0037] The present invention also provides a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the above-mentioned subtitle file encryption method and / or the above-mentioned subtitle file decryption method is implemented.
[0038] The present invention also provides an electronic device, comprising:
[0039] At least one processor, and at least one memory and bus connected to the processor;
[0040] The processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the above-mentioned subtitle file encryption method and / or the above-mentioned subtitle file decryption method.
[0041] The embodiments of the present invention provide a subtitle encryption and decryption method, system, storage medium and electronic device, which convert characters into character representation data through a character comparison table. From the perspective of the client, what appears in the network or memory is not the UTF8 code of the characters in the subtitle file, but the character representation data, thereby strengthening the protection of the characters in the subtitle file. Moreover, the character representation data all correspond to sequence marks, and the encrypted subtitle file obtained by representing the character representation data with the sequence marks further increases the difficulty for illegal users or unauthorized users to crack the characters in the subtitle file. The present invention can solve the problem of subtitle stream being stolen due to plain text transmission of subtitles.
[0042] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A flow chart of a subtitle file encryption method provided by an embodiment of the present invention;
[0045] Figure 2 A structural diagram of a subtitle file encryption system provided by an embodiment of the present invention;
[0046] Figure 3 A flow chart of a subtitle file decryption method provided by an embodiment of the present invention;
[0047] Figure 4 A structural diagram of a subtitle file decryption system provided by an embodiment of the present invention;
[0048] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The present invention provides a subtitle file encryption method, such as Figure 1 As shown, the method includes:
[0051] Step 101: Obtain a subtitle file to be encrypted. The subtitle file includes multiple groups of sentences with play period marks; the sentences include one or more characters.
[0052] When a video is played, subtitles are usually included during the audio playback period. Videos with subtitles help viewers understand the content of the video more clearly. If the language played in the video needs to be translated so that viewers can understand the video content, subtitles in the video are even more necessary. Subtitles transmitted in plain text cannot protect subtitles. In order to protect subtitles, subtitles need to be encrypted.
[0053] A subtitle file is a file that matches playback time periods with playback sentences. During the video playback process, when the video reaches a certain time period (playback period), the sentence (playback sentence) corresponding to the time period can be displayed. In a preset time period, there may be sentences containing multiple characters or sentences with only one character, or even no sentences. For a complete video, the total playback time of the video needs to be divided into multiple playback periods, and then the sentences that need to be presented in each playback period are matched to generate a subtitle file.
[0054] For example, the name of the subtitle file to be encrypted is sub.xml, and a part of the subtitle file is as follows:
[0055] <sub time=135000000>第一句话
[0056] <sub time=135000012>第二句话
[0057] That is, under the file name sub, the sentence "first sentence" is output when the playback period mark is 135000000, and the sentence "second sentence" is output when the playback period mark is 135000012.
[0058] Step 102: According to the character comparison table, character representation data corresponding to the characters in the sentence are obtained; the character representation data is used to represent the characters by data different from the characters, and the character comparison table is used to characterize the correspondence between the characters and the character representation data. Different characters correspond to different character representation data. Each character representation data in the character comparison table has a sequence mark set according to a preset sorting order, and different character representation data have different sequence marks.
[0059] When encrypting the subtitle file, the present invention encrypts the sentences in each playing period as an encrypted subfile. The purpose of this processing method is to decrypt only the sentences in the period to be played in the subsequent decryption process, rather than decrypting all the characters in the encrypted subtitles, to prevent the risk of subtitles being stolen due to premature decryption. At the same time, this method of using the sentences in the playing period as an encrypted subunit will greatly reduce the decryption processing time in the subsequent decryption, avoiding the problem of affecting the normal playback of subtitles due to too long decryption time.
[0060] When the characters in the sentence are represented by character representation data, the character representation data may be generated in the following two ways, which are only exemplary and not specifically limited:
[0061] Method 1: character representation data is generated by using symbolic identifiers such as character strings, graphics, text, numbers or combinations thereof. The characters in the sentence are converted into symbols, and the characters appearing in the subtitles are replaced with different symbolic identifiers, so that the purpose of not being able to know the characters in the subtitles without obtaining the character comparison table is achieved, achieving the effect of encryption.
[0062] Mode 2: The character representation data is the image coding data of the character image. When generating the character representation data, firstly, the character image is acquired, the image coding data of the character image is generated, and the image coding data is used as the character representation data corresponding to the character in the character image.
[0063] When the character representation data is the image coding data of a character image, the character image has a character texture describing the character, and the character texture information can be obtained after the image coding data is restored to the character image. Preferably, the characters in the subtitles are dot matrix fonts. The dot matrix font divides a character into 16*16 or 24*24 dots, and then uses the virtuality and reality of each dot to represent the outline of the character. Dot matrix fonts are also called bitmap fonts, and each glyph is represented by a set of two-dimensional pixel information. In this way, the character representation data is the pixel information array corresponding to the dot matrix font or the binary array converted using the pixel information array. Of course, the character image can also be an image containing only one character. In order to save space, the image coding data of the generated character image is preferably image compression coding. Using image compression coding to store the character image can reduce the storage volume.
[0064] There are three ways to generate a character comparison table, which are only for illustrative purposes and are not intended to be limiting:
[0065] As an implementation method, a method for generating a character comparison table specifically includes: deduplicating characters in a subtitle file to be encrypted to obtain deduplicated characters; selecting character representation data from a first character representation data set to obtain selected character representation data; the selected character representation data is different from the deduplicated characters, and the number of selected character representation data is not less than the number of deduplicated characters; making correspondence between the deduplicated characters and the selected character representation data, so that each deduplicated character corresponds to at least one selected character representation data and the character representation data corresponding to different characters are different, thereby generating a character comparison table.
[0066] Deduplication of characters in the encrypted subtitle file can obtain different characters. Different characters need to be distinguished by different character representation data. The same character representation data can be used to represent the same character. The character representation data and the characters are matched, and the deduplicated characters have at least one character representation data corresponding to them. Optionally, a character has only one character representation data corresponding to it, or a character has two or more character representation data corresponding to it, as long as the character representation data corresponding to the character does not correspond to other characters except the character. When the character representation data is the image encoding data of the character image, since there are many types of fonts for the characters, there are multiple image encoding data of the character images for the same character. Of course, if the character image is a hand-painted image, there are also multiple image encoding data of the corresponding character image. No matter which image encoding data is used, it can uniquely represent the same character.
[0067] This character comparison table generation method is generated for subtitle files. When the subtitle file changes, the characters also change accordingly, and the character comparison table also changes accordingly. Generating a character comparison table for each subtitle file can make the cracker find the character comparison table every time he cracks an encrypted subtitle file. Even if he obtains the character comparison table corresponding to a subtitle file, the comparison table cannot be applied to other subtitle files except the subtitle file, which increases the cracking workload of the cracker.
[0068] For the subtitle file sub.xml to be encrypted, firstly, all characters used by the video in the subtitle file are deduplicated, and the deduplicated characters are obtained as follows, wherein the deduplicated characters are represented by the character array charList.
[0069] charList = ["first", "sentence", "word", "second"]
[0070] Select character representation data from the first character representation data set to obtain the selected character representation data. There are multiple character representation data in the first character representation data set, and at least 5 are selected from the set to correspond to the deduplicated characters. When the character representation data is a symbol identifier such as a string, a graphic, a text, a number or a combination thereof, the character representation data is randomly selected from the first character representation data set; when the character representation data is image encoding data of a character image, the image encoding data of the character image corresponding to the character is selected from the first character representation data set, and at this time, the first character representation data set stores one or more image encoding data corresponding to the character.
[0071] For example, the character representation data '0x1111111' corresponds to "the", the character representation data '0x22222' corresponds to "one", the symbol representation data '0x333333' corresponds to "sentence", the character representation data '0x4444444' corresponds to "word", and the character representation data '0x55555' corresponds to "two".
[0072] In this way, we get the character representation data file textureList = [[0x1111111], [0x22222], [0x333333], [0x4444444], [0x55555]]. The character representation data size corresponding to one character is about 0.2Kbyte. Assuming that a movie has 20,000 non-repeating characters, the file size of this textureList is about 4MByte. After matching the deduplicated characters with the selected character representation data, we get the character comparison table as shown in Table 1.
[0073] Table 1 Character comparison table
[0074] character No. one sentence talk two Characters represent data 0x1111111 0x22222 0x333333 0x4444444 0x55555
[0075] From the client's perspective, the UTF8 codes (8 bits, Unicode Transformation Format, variable-length character encoding for Unicode) of the Chinese characters "First Sentence" and "Second Sentence" in the subtitles have never appeared in the memory or on the network. The characters seen by the user are the result of symbol conversion, that is, what is seen is character representation data, namely, character strings, graphics, text, numbers and their combinations or image encoding data.
[0076] Generate a character comparison table for each subtitle file. Compared with generating a character comparison table for the entire UTF code table, on the one hand, it saves space for storing the character comparison table. On the other hand, since there are relatively few deduplicated characters in a subtitle file, the time to find the corresponding characters from the table during decompression will be shortened, which is conducive to improving the decompression speed. For example, after deduplicating characters in a video, the total number of deduplicated characters is 1000, while the total number of characters is much larger than 1000. In this way, the time to find a matching character from 1000 characters will be much shorter than the time to find a matching character from all characters.
[0077] As another implementation, a method for generating a character comparison table specifically includes: obtaining a commonly used character set and a second character representation data set; the number of character representation data in the second character representation data set is not less than the number of symbols in the commonly used symbol set; selecting character representation data from the second character representation data set to correspond to characters in the commonly used character set, so that each character in the commonly used character set corresponds to at least one character representation data in the second character representation data set and different characters correspond to different character representation data, and generating a character comparison table.
[0078] The characters in the commonly used character set are characters with a high frequency of occurrence. For Chinese characters, the number of Chinese characters is nearly 100,000, but the number of commonly used characters is relatively small. Generally speaking, 1,000 commonly used characters can cover 92% of written materials, 2,000 commonly used characters can cover 98% of written materials, and 3,000 commonly used characters can cover 99% of written materials. Therefore, generating a character comparison table corresponding to the characters in the commonly used character set can meet the needs of subtitles in the video. The number of character representation data in the second character representation data set is not less than the number of symbols in the commonly used symbol set. One character representation data can only correspond to one commonly used character, and one commonly used character can be represented by one or more character representation data. In the case where one commonly used character corresponds to multiple character representation data, when decrypting the subtitle file, the decryption operation can be completed as long as one character is uniquely determined according to the character representation data.
[0079] Compared with generating a character comparison table for the entire UTF code table, using a common character set to generate a character comparison table can also save space for storing the character comparison table. In addition, the number of common characters is in the range of [1000, 4000]. When decompressing, it does not take a long time to search for corresponding characters from the table, which is conducive to improving the decompression speed.
[0080] As another implementation, the generation method of the character look-up table specifically includes: obtaining a correspondence file; the correspondence file includes multiple groups of correspondences between characters and character representation data, where the characters and character representation data in each group of correspondences are different, and the character representation data in different correspondences are different; selecting from the correspondence file the correspondence between the characters that match the characters in the subtitle file to be encrypted and the character representation data, and generating a character look-up table.
[0081] Different from the above two methods for generating the character look-up table, the character look-up table generated in this implementation is generated according to the correspondence between characters and character representation data, that is, the character representation data corresponding to each character is fixed and does not change with different subtitle files, nor is there a random selection from the set of character representation data for each character. This method for generating the character look-up table saves the time for matching character representation data for characters and can improve the encryption speed of subtitle files.
[0082] Each character representation data in the character look-up table has an order mark set according to a preset sorting. There can be multiple ways to generate the preset sorting, such as one of the following two ways, which is only for illustrative purposes and not specifically limited:
[0083] Method 1: The preset sorting is determined according to the arrangement position of the character representation data in the character look-up table in the sentence.
[0084] In this method, because the order of character appearance in each video is different, the character representation data corresponding to the characters is also different. For example, if the character "第" appears first in the subtitle file sub.xml, then the order mark of the character representation data '0x1111111' corresponding to the character "第" is 0. However, the character "第" may not appear first in other videos, so the corresponding order mark is not necessarily 0.
[0085] Method 2: The preset sorting is determined according to the arrangement position of the character representation data in the character look-up table in the character look-up table.
[0086] In this method, the order mark of the character representation data does not change with the order of character appearance. The order mark of the character representation data is determined according to the arrangement position of the character representation data in the character look-up table. For example, if the serial number of the character "第" in the character look-up table is 3, regardless of when "第" appears in the subtitle file, the order mark of the corresponding character representation data is 3.
[0087] Step 103: Replace the characters in the statement with the character representation data corresponding to the characters, represent the characters in the statement with the sequence tags possessed by the character representation data corresponding to the characters, and set the arrangement positions of the sequence tags according to the arrangement positions of the characters in the statement, so as to obtain a sequence tag set corresponding to the statement.
[0088] Represent the characters in the statement with sequence tags. Since the corresponding character representation data can be directly obtained through the sequence tags, and the characters in the statement cannot be directly obtained through the sequence tags, therefore, what the cracker cracks using the sequence tags is not the subtitle file in the video, but the character representation data that is different from the characters in the subtitle file. If you want to further obtain the characters in the subtitle, you need to crack the corresponding relationship between the characters and the character representation data before you can extract the character information in the subtitle. This method can further increase the difficulty and cost of cracking the characters in the subtitle file by illegal users or unauthorized users.
[0089] As an implementation manner, when the preset sorting is determined according to the arrangement positions of the character representation data in the character comparison table in the statement, for the subtitle file sub.xml, the order of character appearance is "the", "first", "sentence", "second", then, through the corresponding relationship between the characters and the character representation data, it can be obtained that the sequence tag of '0x1111111' is 0, the sequence tag of [0x22222] is 1, the sequence tag of [0x333333] is 2, the sequence tag of [0x4444444] is 3, and the sequence tag of [0x55555] is 4. Represent the characters in the statement with the sequence tags possessed by the character representation data corresponding to the characters, and the obtained sequence tag set corresponding to "the first sentence" is [0, 1, 2, 3], and the sequence tag set corresponding to "the second sentence" is [0, 4, 2, 3].
[0090] As another implementation manner, when the preset sorting is determined according to the arrangement positions of the character representation data in the character comparison table in the character comparison table, as shown in Table 1, since the character "the" is in the first position in the character comparison table, the sequence tag of '0x1111111' is 0. Since the arrangement position of the symbol representation in the character comparison table is the same as the arrangement position of the character representation data in the statement, the obtained sequence tag set corresponding to "the first sentence" is [0, 1, 2, 3], and the sequence tag set corresponding to "the second sentence" is [0, 4, 2, 3].
[0091] Step 104: Concatenate the sequence tag set into an encrypted subtitle file according to the playing period of the statement corresponding to the sequence tag set.
[0092] The encrypted subtitle file is a set of multiple sequential markers with playback time periods. The encrypted subtitle file contains neither characters in the original subtitle file nor character representation data corresponding to the characters in the original subtitle file. The encrypted subtitle file has a good subtitle protection effect.
[0093] The subtitle file to be encrypted sub.xml is encrypted to obtain the encrypted subtitle file new_sub.xml.
[0094] Among them, the encrypted subtitle file new_sub.xml is as follows:
[0095] <sub time=135000000>[0,1,2,3] / / 即charList[0],charList[1],charList[2],charList[3]
[0096] <sub time=135000012>[0,4,2,3] / / 即charList[0],charList[4],charList[2],charList[3]
[0097] 通过步骤101-104,能够将待加密的字幕文件sub.xml转变为加密后的字幕文件new_sub.xml和字符表示数据文件textureList。服务器将加密后的字幕文件和字符表示数据文件同时发给客户端,客户端得到服务器发送的这两个文件后,还需要得到字符对照表才能将加密后的字幕文件还原为待加密的字幕文件。由于客户端接收的两个文件中没有出现字幕文件中字符,避免了攻击者从网络或内存中截取。
[0098] 可选的,为了进一步增加字幕保护效果,在得到顺序标记集合之后,还可以对顺序标记集合加密,得到加密后的顺序标记集合。按照加密后的顺序标记集合对应的语句的播放时段,将加密后的顺序标记集合拼接为加密后的字幕文件。
[0099] 本发明还提供一种字幕文件加密系统,如图2所示,该字幕文件加密系统包括:
[0100] 第一文件获取模块201,用于获取待加密的字幕文件;字幕文件包括多组具有播放时段标记的语句;语句包括一个或多个字符。
[0101] 符号转换模块202,用于根据字符对照表,得到与语句中的字符对应的字符表示数据;字符表示数据用于通过与字符不同的数据对字符进行表示,字符对照表用于表征字符与字符表示数据的对应关系,不同字符对应的字符表示数据不同,字符对照表中的各字符表示数据具有按照预设排序设定的顺序标记,不同的字符表示数据具有的顺序标记不同。
[0102] 符号转换模块202,具体包括:
[0103] 字符对照表生成单元,用于采用方式一、方式二和方式三中的至少一种生成字符对照表。
[0104] 方式一具体包括:对待加密的字幕文件中的字符进行去重处理,得到去重后的字符;从第一字符表示数据集合中选取字符表示数据,得到选取的字符表示数据;选取的字符表示数据与去重后的字符不同,并且选取的字符表示数据个数不少于去重后的字符个数;将去重后的字符和选取的字符表示数据进行对应,使每个去重后的字符与至少一个选取的字符表示数据对应且不同字符对应的字符表示数据不同,生成字符对照表;
[0105] 方式二具体包括:获取常用字符集合和第二字符表示数据集合;第二字符表示数据集合中的字符表示数据个数不少于常用符号集合中的符号个数;从第二字符表示数据集合中选取字符表示数据与常用字符集合中的字符进行对应,使常用字符集合中的每个字符与第二字符表示数据集合中的至少一个字符表示数据对应且不同字符对应的字符表示数据不同,生成字符对照表;
[0106] 方式三具体包括:获取对应关系文件;对应关系文件中包括多组字符与字符表示数据的对应关系,每组对应关系中的字符与字符表示数据不同,不同对应关系中的字符表示数据不同;从对应关系文件中选取与待加密的字幕文件中的字符匹配的字符与字符表示数据的对应关系,生成字符对照表。
[0107] 上述三种方式与图1所示步骤102中的字符对照表生成的三种方式类似,不再赘述。
[0108] 符号转换模块202,还包括:
[0109] 预设排序生成单元,用于获得预设排序。
[0110] 作为一种可选的实施方式,预设排序是根据字符对照表中的字符表示数据在语句中的排列位置确定的。
[0111] 作为另一种可选的实施方式,预设排序是根据字符对照表中的字符表示数据在字符对照表中的排列位置确定的。
[0112] 符号转换模块202,还包括:
[0113] 字符表示数据生成,用于获取字符图像;生成字符图像的图像编码数据;将图像编码数据作为与字符图像中的字符对应的字符表示数据。
[0114] 顺序标记集合生成模块203,用于将语句中的字符用与字符对应的字符表示数据代替,并将语句中的字符用字符对应的字符表示数据具有的顺序标记进行表示,且按照字符在语句中的排列位置设置各顺序标记的排列位置,得到与语句对应的顺序标记集合。
[0115] 加密模块204,用于按照顺序标记集合对应的语句的播放时段,将顺序标记集合拼接为加密后的字幕文件。
[0116] 可选的,该字幕文件加密系统,还包括:
[0117] 顺序标记集合加密模块,用于在得到顺序标记集合后,对顺序标记集合加密,得到加密后的顺序标记集合。
[0118] 本发明还提供了一种字幕文件解密方法,如图3所示,其中,字幕文件解密方法与字幕文件加密方法对应,该解密方法包括:
[0119] 步骤301:获取待解密的字幕文件;待解密的字幕文件包括按播放时段顺序拼接的多个顺序标记集合;顺序标记集合包括具有排列顺序的多个顺序标记,顺序标记的排列顺序表征字幕文件的语句中的字符排列顺序。
[0120] 待解密的字幕文件中有多个顺序标记集合,每个顺序标记集合对应一个播放时段,在某一个播放时段即将播放时,对当前播放时段或者即将播放时段对应的顺序标记集合进行解密操作,实现一边观看视频一边解密字幕文件的效果。这种边看边解密的方式相较于全部进行字幕文件解密再播放视频内容来说,能够避免因提早解密带来的字幕破解问题。
[0121] 例如,待解密的字幕文件为new_sub.xml,该待解密的字幕文件中包括有两个顺序标记集合,一个是[0,1,2,3],对应的播放时间为sub time=135000000,另一个是[0,4,2,3],对应的播放时间为sub time=135000012。
[0122] 由于顺序标记的排列顺序表征字幕文件的语句中的字符排列顺序,当顺序标记为0,1,2,3时,表示与0对应的字符排在字幕文件语句中的第一位,与1对应的字符排在字幕文件语句中的第二位,与2对应的字符排在字幕文件语句中的第三位,与3对应的字符排在字幕文件语句中的第四位。
[0123] 步骤302:在待解密的字幕文件中获取与播放时段对应的顺序标记集合,得到顺序标记集合。
[0124] 在播放视频的过程中获取播放时段对应的顺序标记集合,可选的,在视频播放时也可以获取当前播放时段的后几个时段对应的顺序标记集合,这样对后面的顺序标记集合提前进行解密操作,能够防止因解密时间较长而影响视频中字幕的正常播放的风险。
[0125] 若待解密的字幕文件为new_sub.xml,在当前播放时段为135000000时,确定当前顺序标记集合为[0,1,2,3],对该顺序标记集合[0,1,2,3]进行解密操作;在当前播放时段为135000012时,确定当前顺序标记集合为[0,4,2,3],对顺序标记集合[0,4,2,3]进行解密操作。
[0126] 步骤303:将顺序标记集合用具有按照预设排序设定的顺序标记的字符表示数据进行表示,且按照顺序标记在顺序标记集合中的排列位置设置各字符表示数据的排列位置,得到与顺序标记集合对应的字符表示数据集合;字符表示数据用于通过与字符不同的数据对字符进行表示。
[0127] 由于字符表示数据具有按照预设排序设定的顺序标记,因此根据顺序标记即可转换得到与顺序标记对应的字符表示数据。可选的,预设排序有两种生成方式,一种是根据字符对照表中的字符表示数据在语句中的排列位置确定的,另一种是根据字符对照表中的字符表示数据在字符对照表中的排列位置确定的。两种预设排序的生成过程与图1所示步骤102中的预设排序生成方式类似,不再赘述。
[0128] 按照顺序标记在当前顺序标记集合中的排列位置设置各字符表示数据的排列位置,得到与当前顺序标记集合对应的字符表示数据集合。生成的字符表示数据集合中的字符表示数据顺序能够反映出字幕文件的语句中字符出现的顺序。
[0129] 若待解密的字幕文件为new_sub.xml,当前顺序标记集合为[0,1,2,3],与顺序标记0对应的字符表示数据为‘0x1111111’,与顺序标记1对应的字符表示数据为‘0x22222’,与顺序标记2对应的字符表示数据为‘0x333333’,与顺序标记3对应的字符表示数据为‘0x4444444’,按照字符表示数据具有预设的排列顺序可以得到与当前顺序标记集合[0,1,2,3]对应的字符表示数据集合为[0x1111111,0x22222,0x333333,0x4444444]。
[0130] 步骤304:按照字符对照表对字符表示数据集合中的字符表示数据进行字符转换,得到与播放时段对应的字符;字符对照表用于表征字符与字符表示数据的对应关系,不同字符对应的字符表示数据不同。
[0131] 字符表示数据集合中的字符表示数据进行字符转换时,利用字符对照表将字符表示数据转换成字幕文件中的字符,从而解密得到字符。若一个字符对应多个字符表示数据,只要字符表示数据能够唯一标识一个字符即能转换得到相应字符。当字符表示数据为字符图像的图像编码数据时,对字符表示数据进行字符转换时需要对图像编码数据解码还原为字符图像后展示出来,这时在客户端展现的字符是依据编码时字符样式还原得到的,例如对于"中”字,编码时依据的字体类型为宋体表示的"中”字,解码得到的字体类型也为宋体表示的"中”字。当字符表示数据为字符串、图形、文字、数字或者其组合等符号标识时,则通过字符对照表直接得到与字符表示数据对应的字符。
[0132] 若待解密的字幕文件为new_sub.xml,字符表示数据集合为[0x1111111,0x22222,0x333333,0x4444444],对字符表示数据‘0x1111111’进行转换时,查找字符对照表,如表1所示,能够得到对应的字符为"第”;对字符表示数据‘0x22222’进行转换时,查找到对应的字符为"一”;对字符表示数据‘0x333333’进行转换时,查找到对应的字符为"句”;对字符表示数据‘0x4444444’进行转换时,查找到对应的字符为"话”,则与当前播放时段对应的字符分别为第、一、句、话。
[0133] 字符对照表的生成方式有三种,与图1中步骤102的字符对照表的生成方式类似,不再赘述。字符表示数据的生成方式有两种,与图1中步骤102的字符表示数据的生成方式类似,不再赘述。
[0134] 步骤305:将字符按照字符表示数据集合中的字符表示数据排列顺序进行排序,得到与播放时段对应的语句。
[0135] 将字符进行排序后得到当前播放时段对应的语句,至此,完成了从当前播放时段对应的顺序标记集合到与当前播放时段对应的语句的解密操作。在解密过程中是针对一个播放时段进行解密的,播放到哪个时段或者即将播放哪个时段进行解密操作,能够实现边观看视频边生成视频字幕的效果。
[0136] 作为一可选的实施方式,若顺序标记集合为加密后的顺序标记集合,则首先应采用与加密对应的解密方法对加密后的顺序标记集合进行解密后,再执行步骤303。
[0137] 本发明还公开一种字幕文件解密系统,如图4所示,该字幕文件解密系统包括:
[0138] 第二文件获取模块401,用于获取待解密的字幕文件;待解密的字幕文件包括按播放时段顺序拼接的多个顺序标记集合;顺序标记集合包括具有排列顺序的多个顺序标记,顺序标记的排列顺序表征字幕文件的语句中的字符排列顺序。
[0139] 集合获取模块402,用于在待解密的字幕文件中获取与播放时段对应的顺序标记集合,得到顺序标记集合。
[0140] 可选的,若当前顺序标记集合为加密后的顺序标记集合,则执行顺序标记集合解密模块,其中,顺序标记集合解密模块用于对当前顺序标记集合进行解密操作,得到解密后的顺序标记集合。
[0141] 字符表示数据集合生成模块403,用于将顺序标记集合用具有按照预设排序设定的顺序标记的字符表示数据进行表示,且按照顺序标记在顺序标记集合中的排列位置设置各字符表示数据的排列位置,得到与顺序标记集合对应的字符表示数据集合;字符表示数据用于通过与字符不同的数据对字符进行表示。
[0142] 作为一种可选的实施方式,预设排序是根据字符对照表中的字符表示数据在语句中的排列位置确定的。
[0143] 作为另一种可选的实施方式,预设排序是根据字符对照表中的字符表示数据在字符对照表中的排列位置确定的。
[0144] 字符转换模块404,用于按照字符对照表对字符表示数据集合中的字符表示数据进行字符转换,得到与播放时段对应的字符;字符对照表用于表征字符与字符表示数据的对应关系,不同字符对应的字符表示数据不同。
[0145] 字符对照表采用三种方式生成,这三种生成方式与图1所示步骤102中的字符对照表生成的三种方式类似,不再赘述。字符表示数据的生成方式有两种,与图1中步骤102的字符表示数据的生成方式类似,不再赘述。
[0146] 解密模块405,用于将字符按照字符表示数据集合中的字符表示数据排列顺序进行排序,得到与播放时段对应的语句。
[0147] 本发明实施例提供了一种计算机可读存储介质,其上存储有程序,该程序被处理器执行时实现上述的字幕文件加密方法和 / 或字幕文件解密方法。
[0148] 本发明实施例提供了一种电子设备,如图5所示,电子设备50包括至少一个处理器501、以及与处理器501连接的至少一个存储器502、总线503;其中,处理器501、存储器502通过总线503完成相互间的通信;处理器501用于调用存储器502中的程序指令,以执行上述的字幕文件加密方法和 / 或字幕文件解密方法。本文中的电子设备可以是服务器、PC、PAD、手机等。
[0149] 本申请还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有上述的字幕文件加密方法和 / 或字幕文件解密方法包括的步骤的程序。
[0150] 本申请是参照根据本申请实施例的方法、系统和计算机程序产品的流程图和 / 或方框图来描述的。应理解可由计算机程序指令实现流程图和 / 或方框图中的每一流程和 / 或方框、以及流程图和 / 或方框图中的流程和 / 或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和 / 或方框图一个方框或多个方框中指定的功能的装置。
[0151] 在一个典型的配置中,设备包括一个或多个处理器(CPU)、存储器和总线。设备还可以包括输入 / 输出接口、网络接口等。
[0152] 存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和 / 或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。存储器是计算机可读介质的示例。
[0153] 计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
[0154] 本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
[0155] 需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。还需要说明的是,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。
[0156] 本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
[0157] 以上仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。
Claims
1. A subtitle file encryption method, characterized in that: include: Acquire a subtitle file to be encrypted; the subtitle file includes multiple groups of sentences with playback period marks; the sentences include one or more characters; According to the character comparison table, character representation data corresponding to the characters in the sentence are obtained; The character representation data is used to represent the character by data different from the character, the character comparison table is used to characterize the correspondence between the character and the character representation data, different characters correspond to different character representation data, each character representation data in the character comparison table has a sequence mark set according to a preset sorting order, and different character representation data have different sequence marks; Replacing characters in the sentence with character representation data corresponding to the characters, and representing the characters in the sentence with sequence marks possessed by the character representation data corresponding to the characters, and setting the arrangement position of each sequence mark according to the arrangement position of the characters in the sentence, to obtain a sequence mark set corresponding to the sentence; According to the playback time period of the sentence corresponding to the sequence mark set, the sequence mark set is spliced into an encrypted subtitle file; The preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the sentence, or the preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the character comparison table.
2. The subtitle file encryption method according to claim 1, characterized in that: The character comparison table is generated in the following manner: Deduplication processing is performed on the characters in the subtitle file to be encrypted to obtain deduplicated characters; character representation data is selected from the first character representation data set to obtain selected character representation data; the selected character representation data is different from the deduplicated characters, and the number of the selected character representation data is not less than the number of the deduplicated characters; the deduplicated characters and the selected character representation data are matched, so that each of the deduplicated characters corresponds to at least one of the selected character representation data and the character representation data corresponding to different characters are different, and a character comparison table is generated.
3. The subtitle file encryption method according to claim 1, characterized in that: The character comparison table is generated in the following manners: at least one of the first and second manners: The first method specifically includes: obtaining a commonly used character set and a second character representation data set; the number of character representation data in the second character representation data set is not less than the number of symbols in the commonly used character set; selecting character representation data from the second character representation data set to correspond to characters in the commonly used character set, so that each character in the commonly used character set corresponds to at least one character representation data in the second character representation data set and different characters correspond to different character representation data, and generating a character comparison table; The second method specifically includes: obtaining a correspondence relationship file; the correspondence relationship file includes a plurality of groups of correspondence relationships between characters and character representation data, the characters and character representation data in each group of the correspondence relationships are different, and the character representation data in different correspondence relationships are different; selecting the correspondence relationship between the characters and character representation data that matches the characters in the subtitle file to be encrypted from the correspondence relationship file to generate a character comparison table.
4. The subtitle file encryption method according to any one of claims 1 to 3, characterized in that: The method for generating the character representation data specifically includes: Get character image; generating image coding data of the character image; The image encoding data is used as character representation data corresponding to the characters in the character image.
5. A subtitle file encryption system, characterized in that: include: A first file acquisition module is used to acquire a subtitle file to be encrypted; the subtitle file includes a plurality of sentences with playback period marks; the sentences include one or more characters; A character representation module, used for obtaining character representation data corresponding to the characters in the sentence according to a character comparison table; the character representation data is used to represent the characters by data different from the characters, the character comparison table is used to characterize the correspondence between the characters and the character representation data, different characters correspond to different character representation data, each character representation data in the character comparison table has a sequence mark set according to a preset order, and different character representation data have different sequence marks, wherein the preset order is determined according to the arrangement position of the character representation data in the character comparison table in the sentence, or the preset order is determined according to the arrangement position of the character representation data in the character comparison table in the character comparison table; A sequence mark set generation module, used for replacing characters in the sentence with character representation data corresponding to the characters, and representing the characters in the sentence with sequence marks possessed by the character representation data corresponding to the characters, and setting the arrangement position of each sequence mark according to the arrangement position of the characters in the sentence, to obtain a sequence mark set corresponding to the sentence; The encryption module is used to splice the sequence mark set into an encrypted subtitle file according to the playing time period of the sentence corresponding to the sequence mark set.
6. A subtitle file decryption method, characterized in that: include: Get the subtitle file to be decrypted; The subtitle file to be decrypted includes a plurality of sequence mark sets spliced in the order of the playback time period; the sequence mark set includes a plurality of sequence marks having an arrangement order, and the arrangement order of the sequence marks represents the arrangement order of characters in the sentence of the subtitle file; Obtaining a sequence mark set corresponding to the playback period in the subtitle file to be decrypted, to obtain a sequence mark set; The sequential mark set is represented by character representation data having sequential marks set in a preset order, and the arrangement position of each character representation data is set according to the arrangement position of the sequential marks in the sequential mark set, so as to obtain a character representation data set corresponding to the sequential mark set; the character representation data is used to represent the character by data different from the character; Performing character conversion on the character representation data in the character representation data set according to the character comparison table to obtain characters corresponding to the playback time period; the character comparison table is used to represent the correspondence between characters and character representation data, and different characters correspond to different character representation data; Sorting the characters according to the character representation data arrangement order in the character representation data set to obtain a sentence corresponding to the playback time period; The preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the sentence, or the preset sorting is determined according to the arrangement position of the character representation data in the character comparison table in the character comparison table.
7. A subtitle file decryption system, characterized in that: include: A second file acquisition module, used to acquire a subtitle file to be decrypted; The subtitle file to be decrypted includes a plurality of sequence mark sets spliced in the order of the playback time period; the sequence mark set includes a plurality of sequence marks having an arrangement order, and the arrangement order of the sequence marks represents the arrangement order of characters in the sentence of the subtitle file; A set acquisition module, used to acquire a sequence mark set corresponding to a playback period in the subtitle file to be decrypted, to obtain a sequence mark set; A character representation data set generation module, used for representing the sequential mark set with character representation data having sequential marks set according to a preset order, and setting the arrangement position of each character representation data according to the arrangement position of the sequential marks in the sequential mark set, so as to obtain a character representation data set corresponding to the sequential mark set; the character representation data is used for representing the characters by data different from the characters, wherein the preset order is determined according to the arrangement position of the character representation data in the character comparison table in the sentence, or the preset order is determined according to the arrangement position of the character representation data in the character comparison table in the character comparison table; A character conversion module, used for performing character conversion on the character representation data in the character representation data set according to a character comparison table to obtain characters corresponding to the play time period; the character comparison table is used to represent the correspondence between characters and character representation data, and different characters correspond to different character representation data; The decryption module is used to sort the characters according to the character representation data arrangement order in the character representation data set to obtain a sentence corresponding to the playback time period.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed by the processor, the subtitle file encryption method according to any one of claims 1 to 4 and / or the subtitle file decryption method according to claim 6 are implemented.
9. An electronic device, characterized in that: include: At least one processor, and at least one memory and bus connected to the processor; The processor and the memory communicate with each other via the bus; The processor is used to call the program instructions in the memory to execute the subtitle file encryption method according to any one of claims 1 to 4 and / or the subtitle file decryption method according to claim 6.
