Video stream encryption transmission method and system
By slicing video slices and generating associated keys for each slice for encryption transmission, and using the playback permission encryption key of the target video, the security and efficiency problems of video surveillance data are solved during the transmission of video surveillance data on the network, and efficient and secure encrypted video streams are achieved.
Patent Information
- Application Number
- CN202411161878.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-08-23
AI Technical Summary
Existing video surveillance data is easily intercepted and tampered when transmitted in public and mobile networks, and the encryption and decryption process takes a long time, playback speed is slow, and keys are easily cracked and forged.
A video stream encryption transmission method is proposed, which is encrypted and transmitted by slicing the video slice and generating an associated key for each slice, and encrypting the key using the playback permission of the target video, and issuing it to the client for decryption.
It reduces the calculation amount of single encryption and decryption operations, improves the efficiency of video encryption and decryption, reduces user waiting time, and enhances the confidentiality of video transmission, preventing keys from being cracked and forged.
Smart Images

Figure CN118870059B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a video stream encryption transmission method and system. Background Art
[0002] In the field of video surveillance, the secure transmission of video data is an important issue, especially in public and mobile networks, where surveillance video data can be easily intercepted and tampered with, leading to data leakage and malicious attacks. To resist tampering attacks during surveillance video transmission, the current solution is to encrypt the surveillance video stream at the sender and transmit it to the user end, and the user end then decrypts the surveillance video according to the key entered by the user. However, this type of solution has two main problems:
[0003] On the one hand, due to the large amount of video data, it takes a long time to encrypt and decrypt the video, resulting in a slow video playback speed.
[0004] On the other hand, in this scheme, the key is pre-stored at the sender and in the hands of the user. Due to the uniqueness of the key, the key may be cracked through a limited number of attack calculations. In addition, the attacker may also obtain the key by forging the user's identity during the key distribution phase. Summary of the invention
[0005] Purpose of the invention: The present invention aims to at least partially overcome the above-mentioned technical problems and proposes a video stream encryption transmission method and system.
[0006] Invention content: To achieve the above objectives, the present invention proposes the following technical solutions:
[0007] In a first aspect, a video stream encryption transmission method is provided, which is applicable to a platform end, and the method includes:
[0008] In response to a transmission request for a target video from a client, slicing the target video to obtain video slice data;
[0009] Generate an associated key for each of the video slice data;
[0010] Encrypting the video slice data using the key, and transmitting the encrypted video slice data to the client;
[0011] Encrypting the key using the playback permission of the target video to obtain an encrypted key;
[0012] The encryption key is sent to the client, so that the client can decrypt the encryption key based on user authority data, and decrypt the received encrypted video slice data according to the key obtained by decryption.
[0013] As an optional implementation manner of the method of the first aspect, the specific steps of slicing the target video include:
[0014] The target video is divided into a plurality of TS slices to obtain the video slice data;
[0015] The m3u8 file is used to record the playback order and storage address of the video slice data.
[0016] As an optional implementation manner of the method according to the first aspect, generating a key for the video slice data specifically includes:
[0017] Generating an associated character string as an initial key for the video slice data;
[0018] Converting the initial key into a first ASCII code string, and determining a first position sequence of characters in the first ASCII code string in an ASCII code table;
[0019] Generate a displacement vector, and perform displacement transformation on the first position sequence based on the displacement vector in an ASCII code table to obtain a second position sequence;
[0020] In the ASCII code table, based on the second position sequence, obtain a second ASCII code string;
[0021] The key is determined based on the second ASCII code string.
[0022] Furthermore, the method for generating the displacement vector specifically includes:
[0023] Generate up and down movement symbol Cr:
[0024] Cr=Smid / ABS(Smmid)
[0025] Smid=Smax×RAN()+0.5-Smax / 2
[0026] Where Smax represents the maximum step length of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, Cr is positive, indicating that the corresponding character is moved up in the ASCII code table, and Cr is negative, indicating that the corresponding character is moved down in the ASCII code table;
[0027] Determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length;
[0028] Determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function, and Rmax represents the maximum random transition step length;
[0029] A second displacement vector C2 is determined as the displacement vector; wherein C2=C1+R*S2, S2 represents the random movement distance, and S2=SIGN.
[0030] Further, in the ASCII code table, based on the second position sequence, a second ASCII code string is obtained, specifically including:
[0031] In the ASCII code table, based on the second position sequence, determining a corresponding ASCII code;
[0032] Randomly determine Ns characters in the ASCII code table, and exchange the selected Ns characters with any Ns characters in the ASCII code to obtain the second ASCII code string.
[0033] In a second aspect, a video stream encryption transmission system is provided, the system comprising: a platform end and a client end;
[0034] The platform end is configured to: in response to the transmission request of the client for the target video, slice the target video to obtain video slice data; generate a key for the video slice data; encrypt the video slice data using the key, and transmit the encrypted video slice data to the client; encrypt the key using the playback permission of the target video to obtain an encryption key, and send the encryption key to the client;
[0035] The client is configured to: in response to obtaining the encryption key and the encrypted video slice data issued by the platform, use user authority data to decrypt the encryption key to obtain the key; use the key to decrypt the encrypted video slice data; and sequentially play the decrypted video slice data.
[0036] As an optional implementation of the system according to the second aspect, the platform side includes:
[0037] A first data acquisition module, configured to acquire the target video in response to a transmission request of the client for the target video;
[0038] A video slicing module, used for slicing the target video slice to obtain the video slice data;
[0039] A key generation module, used to generate the key for the video slice data;
[0040] The encryption module is used to encrypt the video slice data using the key and transmit the encrypted video slice data to the client; encrypt the key using the playback permission of the target video to obtain the encryption key, and send the encryption key to the client.
[0041] Furthermore, the key generation module is specifically used for:
[0042] Generating an associated character string as an initial key for the video slice data;
[0043] Converting the initial key into a first ASCII code string, and determining a first position sequence of characters in the first ASCII code string in an ASCII code table;
[0044] Generate a displacement vector, and perform displacement transformation on the first position sequence based on the displacement vector in an ASCII code table to obtain a second position sequence;
[0045] In the ASCII code table, based on the second position sequence, obtain a second ASCII code string;
[0046] The key is determined based on the second ASCII code string.
[0047] Furthermore, the key generation module is also specifically used for:
[0048] Generate up and down movement symbol Cr:
[0049] Cr=Smid / ABS(Smid)
[0050] Smid=Smax×RAN()+0.5-Smax / 2
[0051] Where Smax represents the maximum step length of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, Cr is positive, indicating that the corresponding character is moved up in the ASCII code table, and Cr is negative, indicating that the corresponding character is moved down in the ASCII code table;
[0052] Determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length;
[0053] Determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function, and Rmax represents the maximum random transition step length;
[0054] A second displacement vector C2 is determined as the displacement vector; wherein C2=C1+R*S2, S2 represents the random movement distance, and S2=SIGN.
[0055] Furthermore, the key generation module is also specifically used for:
[0056] In the ASCII code table, based on the second position sequence, determining a corresponding ASCII code;
[0057] Randomly determine Ns characters in the ASCII code table, and exchange the selected Ns characters with any Ns characters in the ASCII code to obtain the second ASCII code string.
[0058] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0059] The present invention provides a video stream encryption transmission method and system, which can reduce the computational complexity of a single encryption and decryption operation by slicing a video and encrypting and decrypting the video slice data respectively. The encrypted video slices can be transmitted immediately, and can be decrypted and played according to the order of the video slices on the client side. Each video slice can be played after it is decrypted, thereby reducing user waiting time and improving the efficiency of video encryption and decryption.
[0060] On the other hand, in this method, the key is not distributed directly to the user, but is encrypted and then distributed to the client. The client needs to obtain the user's permission information to decrypt the key. In this way, it is difficult for an attacker to obtain the key during the key distribution stage by forging the user's identity.
[0061] In addition, the key used to encrypt each video slice at the sending end is different and is only associated with the video slice. It is difficult for attackers to attack and calculate a large number of keys in a short period of time, thereby effectively improving the confidentiality of video transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the embodiments of this specification 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 some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0063] Figure 1 It is a flowchart of a video stream encryption transmission method involved in the embodiments of this specification.
[0064] Figure 2It is a structural diagram of a video stream encryption transmission system involved in the embodiments of this specification.
[0065] Figure 3 It is a structural diagram of the platform end involved in the embodiments of this specification. DETAILED DESCRIPTION
[0066] First of all, it should be noted that the terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise.
[0067] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, rather than all the embodiments. Therefore, it should be recognized by those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0068] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0069] This specification aims to address the problems of slow playback speed and poor confidentiality of current surveillance video data encryption transmission solutions, and to propose a video stream encryption transmission method and system to at least partially overcome the above-mentioned defects.
[0070] The following will further describe in detail a video stream encryption transmission method and system described in one or more embodiments of this specification in conjunction with the accompanying drawings and specific embodiments. However, this detailed description does not constitute a limitation on the embodiments of this specification.
[0071] Please refer to Figure 1 , Figure 1 A schematic diagram of a video stream encryption transmission method is given below. Figure 1 As shown, the method is applicable to the platform side, and the method includes steps S100 to S108.
[0072] S100: In response to a transmission request for a target video from a client, the target video is sliced to obtain video slice data.
[0073] In some implementations, the target video may be segmented into a number of TS slices to obtain the video slice data, and then the m3u8 file may be used to record the playback order and storage address of the video slices.
[0074] Specifically, the target video can be converted into an m3u8 file through FFmpeg, and the video file input path, slice file output path and the duration of each slice can be set in FFmpeg to complete the video slicing process. In order to increase the transcoding rate, the video slicing process can also be implemented using multithreading, and the appropriate slice duration can be selected to ensure processing efficiency.
[0075] The specific process of converting the target video to m3u8 file through FFmpeg is as follows:
[0076] S1000: Install dependencies and download FFmpeg in the system.
[0077] FFmpeg is an audio and video codec tool, and also a set of audio and video coding development kits. As a coding development kit, it provides developers with a rich calling interface for audio and video processing. FFmpeg provides encapsulation and decapsulation of various media formats, including various audio and video encodings, streaming media of various protocols, various colorful format conversions, various sampling rate conversions, and various bit rate conversions; the FFmpeg framework provides a variety of rich plug-in modules, including plug-ins for encapsulation and decapsulation, plug-ins for encoding and decoding, etc. It can also be used to record, convert digital audio and video, and can convert them into streams. It is an open source computer program. It uses LGPL or GPL licenses. It provides a complete solution for recording, converting, and streaming audio and video.
[0078] S1002: Transcode and slice m3u8
[0079] (a) Configure the htm1 path in nginx, which corresponds to the html folder under the nginx directory, to store the m3u8 files and ts files generated by FFmpeg.
[0080] (b) Use FFmpeg command to perform transcoding and slice to generate m3u8 files and store them in the above folder.
[0081] The main slicing commands are as follows:
[0082] ffmpeg: This is the command that calls the FFmpeg program.
[0083] -c copy: This means that the encoding of the input file will be copied directly whenever possible without re-encoding. This can make the conversion process faster.
[0084] -map 0: This means select all streams (video, audio, subtitles, etc.) from the input file for copying.
[0085] -vbsf h264 _ mp4toannexb: This is a video bitstream filter that converts H.264 encoded MP4 video to Annex B format. This is because HLS requires the video to be segmented in Annex B format.
[0086] -f: This specifies the output format.
[0087] -time: This specifies the duration of each segment.
[0088] -filename This is the output path and name of the playlist (.m3u8 file).
[0089] For the slice duration, it can be set according to demand, and this embodiment does not limit this. Generally, the size of the slice file should be small enough to facilitate fast loading and smooth playback. Slicing too large may cause the loading time to be too long, while slicing too small may increase the number and management complexity of m3u8 files. It is generally recommended that the size of each slice is between 1MB and 5MB. The system selects a slice file size of about 5MB. For example, 3 seconds, 6 seconds and 10 seconds can be selected as the slice duration. From the perspective of viewing experience, content and network environment considerations, this embodiment selects about 10 seconds of video playback to be more stable.
[0090] (c) Finally, use nginx proxy to export the .m3u8 video link address for playback.
[0091] S102: Generate an associated key for each video slice data.
[0092] For each video slice data of each target video, the platform randomly generates an associated key for the video slice data.
[0093] Specifically, the steps for generating keys on the platform are:
[0094] S1020: Generate an associated character string as an initial key for the video slice data.
[0095] Specifically, Rn characters may be randomly selected from a preset character set to form a character string to serve as the above-mentioned initial key, and the initial key may be associated with the video slice data.
[0096] Rn=INT(Nmax-Nmin)×RAN()+Nmin
[0097] Where Nmax and Nmin are the upper and lower bounds of the character set respectively, INT is the rounding function, and RAN() is a random number between 0 and 1.
[0098] S1022: Convert the initial key into a first ASCII code string, and determine a first position sequence of characters in the first ASCII code string in the ASCII code table.
[0099] After the initial key is converted into the first ASCII code, each character in the initial key corresponds to a position of an ASCII code in the ASCII code table, thereby obtaining the above-mentioned first position sequence.
[0100] S1024: Generate a displacement vector, and perform displacement transformation on the first position sequence based on the displacement vector in the ASCII code table to obtain a second position sequence.
[0101] The above displacement vector can be generated in the following way:
[0102] First determine the up and down symbols Cr that move up (plus) or down (minus) in the ASCII code table
[0103] Cr=Smid / ABS(Smid)
[0104] Smid=Smax×RAN()+0.5-Smax / 2
[0105] Among them, Smax represents the maximum step size of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, and Cr is positive, which means that the corresponding character is moved up in the ASCII code table. r | distance, Cr is negative, which means the corresponding character is moved down in the ASCII code table |C r |Distance;
[0106] Then determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length;
[0107] Then determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function and Rmax represents the maximum random transition step length;
[0108] Then, a second displacement vector C2 is determined as the above displacement vector; wherein, C2=C1+R*S2, S2 represents the random movement distance, and S2=SIGN.
[0109] S1026: In the ASCII code table, based on the second position sequence, obtain a second ASCII code string.
[0110] Specifically, in the ASCII code table, the corresponding ASCII code can be determined based on the second position sequence. Then, Ns characters are randomly determined in the ASCII code table, and the selected Ns characters are exchanged with any Ns characters in the ASCII code to obtain a second ASCII code string.
[0111] S1028: Determine a key based on the second ASCII code string.
[0112] After obtaining the second ASCII code string, each ASCII code in the second ASCII code string can be subjected to upper and lower bound processing, that is, if the value of the ASCII code is greater than 254 (OFEH), it is subtracted by 254; if it is less than 0, it is added by 254.
[0113] The second ASCII code string after the upper and lower bounds are processed can be converted into a character form in the same format as the initial key through an ASCII code table, thereby obtaining the above key.
[0114] S104: Encrypt the video slice data using the key, and transmit the encrypted video slice data to the client.
[0115] Specifically, a number can be added to the header of the encrypted video slice data, and this number is the number of the video slice data. Based on this, the video slice can be encrypted in parallel, and each encrypted video slice data is transmitted to the client, thereby shortening the loading time of the client.
[0116] S106: Encrypt the key using the playback permission of the target video to obtain an encryption key.
[0117] Considering that the playback permission requirements of each target video are different, the playback permission of the target video can be used to encrypt the above key. Specifically, the playback permission can be mapped to token1, and then the token1 is used to encrypt the above key.
[0118] S108: Send the encryption key to the client, so that the client can decrypt the encryption key based on the user authority data, and decrypt the received encrypted video slice data according to the decrypted key.
[0119] When a user logs in to the client, the client can obtain the user authority data assigned to the user by the system based on the account number and key entered by the user. The client can determine the legitimacy of the user's identity based on the authority data, and can also match the user authority data with the playback authority of the encryption key. If the authorities match, the client can use the user authority data to decrypt the encryption key, thereby enabling the client to obtain the key.
[0120] In some implementations, the user permission data may be mapped to token2, and then the consistency of token1 and token2 may be verified. Based on the consistency verification result of token1 and token2, it may be determined whether the user permission data matches the playback permission of the encryption key.
[0121] In some implementations, after obtaining the above-mentioned key, the client can decrypt the received video slice data. The decryption process can also be performed in parallel. The client can sequentially decrypt the received encrypted video slice data, and each time a video slice data is decrypted, the video slice data can be played.
[0122] Corresponding to the above-mentioned video stream encryption transmission method, this embodiment also provides a video stream encryption transmission system. It should be noted that the video stream encryption transmission method described in this embodiment can be implemented by relying on the video stream encryption transmission system, but is not limited to the video stream encryption transmission system.
[0123] Please refer to Figure 2 , Figure 2 The structure diagram of a video stream encryption transmission system is schematically shown. Figure 2 As shown, the system includes: a platform end and a client end; wherein:
[0124] The platform is configured as follows: in response to a transmission request for a target video from a client, the target video is sliced to obtain video slice data; a key is generated for the target video; the video slice data of the target video is encrypted using the key, and the encrypted video slice data is transmitted to the client; the key is encrypted using the playback permission of the target video, an encryption key is obtained, and the encryption key is sent to the client.
[0125] The client is configured as follows: in response to obtaining the encryption key and encrypted video slice data issued by the platform, using the user authority data to decrypt the encryption key to obtain the key; using the key to decrypt the encrypted video slice data; and sequentially playing the decrypted video slice data.
[0126] Please refer to Figure 3 Specifically, the above platform mainly includes:
[0127] The first data acquisition module 301 is used to acquire a target video in response to a transmission request for the target video from a client.
[0128] The video slicing module 302 is used to slice the target video to obtain video slice data.
[0129] The key generation module 303 is used to generate a key for the target video.
[0130] The encryption module 304 is used to encrypt the video slice data of the target video using the key and transmit the encrypted video slice data to the client; encrypt the above key using the playback permission of the target video to obtain the encryption key, and send the encryption key to the client.
[0131] The following uses the Hikvision security platform as an example to explain the working principles of the above modules.
[0132] For the first data acquisition module 301, the Hikvision security platform has entered multiple monitoring point equipment information, and the MGC streaming service is installed in the Hikvision security platform to realize the function of the first data acquisition module 301. The first data acquisition module 301 obtains the monitoring point preview streaming URL through the openAPI, and the protocol types include: hik, rtsp, rtmp, hls, ws, Wss, etc. The monitoring point video can be played on the client through the WEB development kit of the open platform.
[0133] With respect to the above-mentioned video slicing module 302, the video slicing module 302 can divide the target video into a number of TS slices to obtain the video slices, and then use the m3u8 file to record the playback order and storage address of the video slices.
[0134] Specifically, the video slicing module 302 can convert the target video into an m3u8 file through FFmpeg, and set the input path of the video file, the output path of the slice file and the duration of each slice in FFmpeg to complete the video slicing process. In order to improve the transcoding rate, the video slicing process can also be implemented using multithreading, and the appropriate slice duration is selected to ensure the efficiency of the processing.
[0135] Regarding the above-mentioned key generation module 303, the key generation module 303 is specifically used to generate an associated character string for the video slice data as an initial key; convert the initial key into a first ASCII code string, and determine the first position sequence of the characters in the first ASCII code string in the ASCII code table; then generate a displacement vector, and perform a displacement transformation on the first position sequence in the ASCII code table based on the displacement vector to obtain a second position sequence; finally, in the ASCII code table, based on the second position sequence, obtain a second ASCII code string, and determine the key based on the second ASCII code string.
[0136] In some implementations, the specific steps of the key generation module 303 generating the initial key are:
[0137] The key generation module 303 randomly extracts Rn characters from a preset character set to form a character string as the above-mentioned initial key, and associates the initial key with the video slice data.
[0138] Rn=INT(Nmax-Nmin)×RAN()+Nmin
[0139] Where Nmax and Nmin are the upper and lower bounds of the character set respectively, INT is the rounding function, and RAN() is a random number between 0 and 1.
[0140] In some implementations, the key generation module 303 is further configured to:
[0141] Generate up and down movement symbol Cr:
[0142] Cr=Smid / ABS(Smid)
[0143] Smid=Smax×RAN()+0.5-Smax / 2
[0144] Among them, Smax represents the maximum step size of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, and Cr is positive, which means that the corresponding character is moved up in the ASCII code table. r | distance, Cr is negative, which means the corresponding character is moved down in the ASCII code table |C r |Distance;
[0145] Determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length;
[0146] Determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function, and Rmax represents the maximum random transition step length;
[0147] A second displacement vector C2 is determined as a displacement vector; wherein C2=C1+R*S2, S2 represents a random moving distance, and S2=SIGN.
[0148] Optionally, the key generation module 303 may also be used to: determine the corresponding ASCII code in the ASCII code table based on the second position sequence; then randomly determine Ns characters in the ASCII code table, and exchange the selected Ns characters with any Ns characters in the ASCII code to obtain a second ASCII code string.
[0149] After obtaining the second ASCII code string, the key generation module 303 can also perform upper and lower bound processing on each ASCII code in the second ASCII code string. That is, if the value of the ASCII code is greater than 254 (OFEH), it is subtracted by 254; if it is less than 0, it is added by 254. For the second ASCII code string after upper and lower bound processing, the key generation module 303 can convert it into a character form with the same format as the initial key through the ASCII code table, thereby obtaining the above-mentioned key.
[0150] Considering that the playback permission requirements for each target video are different, in the above-mentioned Hikvision security platform, the video playback permission token1 can be used to encrypt the above-mentioned key. Specifically, the parsed part of the playback permission token1 and the unique code of the video camera can be used together as the key to open the encryption key, and the encryption key is stored in the cache redis of the Hikvision security platform. In the key distribution stage, the Hikvision security platform implements the key distribution mechanism based on the secure communication protocol HTTPS to securely send the encryption key to the client.
[0151] When a user logs in to the client, the client can obtain the user authority data assigned to the user by the system based on the account number and key entered by the user. The client can determine the legitimacy of the user's identity based on the authority data, and can also match the user authority data with the playback authority of the encryption key. If the authorities match, the client can use the user authority data to decrypt the encryption key, thereby enabling the client to obtain the key.
[0152] In some implementations, the user permission data may be mapped to token2, and then the consistency of token1 and token2 may be verified. Based on the consistency verification result of token1 and token2, it may be determined whether the user permission data matches the playback permission of the encryption key.
[0153] It is to be understood that the structure illustrated in the embodiments of this specification does not constitute a specific limitation on the system of the embodiments of this specification. In other embodiments of the specification, the above system may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0154] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0155] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0156] It should be noted that the above examples are only specific embodiments of the present invention, and the present invention is obviously not limited to the above examples, and there are many similar variations. All variations directly derived or associated from the contents disclosed by the technicians in this field should fall within the protection scope of the present invention.
Claims
1. A video stream encryption transmission method, applicable to a platform end, characterized in that: The method comprises: In response to a transmission request for a target video from a client, slicing the target video to obtain video slice data; Generate an associated key for each of the video slice data, specifically including: generating an associated string for the video slice data as an initial key; converting the initial key into a first ASCII code string, and determining a first position sequence of characters in the first ASCII code string in an ASCII code table; generating a displacement vector, and performing a displacement transformation on the first position sequence in the ASCII code table based on the displacement vector to obtain a second position sequence; in the ASCII code table, obtaining a second ASCII code string based on the second position sequence; and determining the key based on the second ASCII code string; Encrypting the video slice data using the key, and transmitting the encrypted video slice data to the client; Encrypting the key using the playback permission of the target video to obtain an encrypted key; The encryption key is sent to the client, so that the client can decrypt the encryption key based on user authority data, and decrypt the received encrypted video slice data according to the key obtained by decryption.
2. The method according to claim 1, characterized in that The specific steps of slicing the target video include: The target video is divided into a plurality of TS slices to obtain the video slice data; The m3u8 file is used to record the playback order and storage address of the video slice data.
3. The method according to claim 1, characterized in that The method for generating the displacement vector specifically includes: Generate up and down movement symbol Cr: Cr=Smid / ABS(Smid) Smid=Smax×RAN()+0.5-Smax / 2 Among them, Smax represents the maximum step size of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, and Cr is positive, which means that the corresponding character is moved up in the ASCII code table. r | distance, Cr is negative, which means the corresponding character is moved down in the ASCII code table |C r |Distance; Determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length; Determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function, and Rmax represents the maximum random transition step length; A second displacement vector C2 is determined as the displacement vector; wherein C2=C1+R*S2, S2 represents the random movement distance, and S2=SIGN.
4. The method according to claim 3, characterized in that In the ASCII code table, based on the second position sequence, a second ASCII code string is obtained, specifically including: In the ASCII code table, based on the second position sequence, determining a corresponding ASCII code; Randomly determine Ns characters in the ASCII code table, and exchange the selected Ns characters with any Ns characters in the ASCII code to obtain the second ASCII code string.
5. A video stream encryption transmission system, characterized in that: include: Platform side and client side; The platform end is configured to: in response to the transmission request of the client for the target video, slice the target video to obtain video slice data; generate a key for the video slice data; The video slice data is encrypted using the key, and the encrypted video slice data is transmitted to the client; the key is encrypted using the playback permission of the target video to obtain an encryption key, and the encryption key is sent to the client; The specific method for the platform end to generate a key for the video slice data includes: generating an associated character string for the video slice data as an initial key; converting the initial key into a first ASCII code string, and determining a first position sequence of characters in the first ASCII code string in an ASCII code table; generating a displacement vector, and performing a displacement transformation on the first position sequence in the ASCII code table based on the displacement vector to obtain a second position sequence; in the ASCII code table, obtaining a second ASCII code string based on the second position sequence; and determining the key based on the second ASCII code string; The client is configured to: in response to obtaining the encryption key and the encrypted video slice data issued by the platform, use user authority data to decrypt the encryption key to obtain the key; use the key to decrypt the encrypted video slice data; and sequentially play the decrypted video slice data.
6. The system according to claim 5, characterized in that The platform end includes: A first data acquisition module, configured to acquire the target video in response to a transmission request of the client for the target video; A video slicing module, used for slicing the target video slice to obtain the video slice data; A key generation module, used to generate the key for the video slice data; The encryption module is used to encrypt the video slice data using the key and transmit the encrypted video slice data to the client; encrypt the key using the playback permission of the target video to obtain the encryption key, and send the encryption key to the client.
7. The system according to claim 6, characterized in that The key generation module is also specifically used for: Generate up and down movement symbol Cr: Cr=Smid / ABS(Smid) Smid=Smax×RAN()+0.5-Smax / 2 Among them, Smax represents the maximum step size of moving up and down, RAN() represents a random number between 0 and 1, ABS represents the absolute value function, and Cr is positive, which means that the corresponding character is moved up in the ASCII code table. r | distance, Cr is negative, which means the corresponding character is moved down in the ASCII code table |C r |Distance; Determine the first displacement vector C1, C1 = P + S1 × LEAP, where P is the randomly generated initial position, S1 = Cr, and LEAP represents a fixed moving step length; Determine the random bit shift step length R, R = INT [Rmax × RAN () + 0.5], where INT represents the rounding function, and Rmax represents the maximum random transition step length; A second displacement vector C2 is determined as the displacement vector; wherein C2=C1+R*S2, S2 represents the random movement distance, and S2=SIGN.
8. The system according to claim 7, characterized in that The key generation module is also specifically used for: In the ASCII code table, based on the second position sequence, determining a corresponding ASCII code; Randomly determine Ns characters in the ASCII code table, and exchange the selected Ns characters with any Ns characters in the ASCII code to obtain the second ASCII code string.
Citation Information
Patent Citations
Local video playing system and method based on HLS
CN110798714A