A kind of video-encryption, decryption method and device
Technical field
The present invention relates to communication technical field, particularly a kind of video-encryption, decryption method and device.
Background technology
Along with the development of the network communications technology, network bandwidth is more and more wider, and network speed is also more and more faster, and increasing student selects to carry out on-line study by the Internet.The existing video player that network courses is provided, all video datas corresponding to its network courses that can provide are kept in video server corresponding to player, after player receives play instruction, the video data extracting corresponding course from video server is play.But malicious third parties can crack it, illegal acquisition network courses video data, is undertaken propagating, selling by back door.Usurping the problem of video data in order to solve malicious third parties, usually can be encrypted video data at present.
Existing video encryption method is encrypted all video datas.Greatly, expend system resource many, and cryptographic algorithm is single, Cipher Strength is weak for encryption, decrypt operation amount.
In addition, split because encrypt file does not do, be not easy to cdn distribution, real network is play limited and cannot carry out seek operation.
Summary of the invention
In order to overcome the deficiencies in the prior art, the invention provides a kind of video-encryption, decryption method and device, solving the operand that exists in prior art large, expend that system resource is many, cryptographic algorithm is single and be not easy to the technical problems such as cdn distribution.
The technical solution adopted for the present invention to solve the technical problems is:
The invention provides a kind of video encryption method, described method comprises:
Obtain all video frame images in video data corresponding to video file;
Key frame quantity is set by configuration file, chooses the key frame video file of some in all video frame images (the key frame quantity namely arranged in configuration file);
The key frame video file chosen is carried out segmentation slicing treatment, becomes video segment file to be encrypted;
The one of the multiple encryption algorithms preset in random selecting configuration file is encrypted corresponding video segment file, obtains the video data after encrypting to all video segments after being encrypted.
Further, before obtaining all video frame images in video data corresponding to video file, first-selected to needing the video file be encrypted to carry out consolidation form conversion, so that subsequent slice encryption.
Further, the key frame video file chosen is carried out segmentation slicing treatment, comprising:
Create video segment listing file;
Video file is cut into slices, and corresponding slice information is write described video segment listing file.
Further, described video encryption method also comprises:
Utilize secret key group to be encrypted to the final video segment listing file obtained, ciphertext is supplied to decryption portion.
The invention provides a kind of decryption of video method, described method comprises:
Player encrypted by Network Capture after video segment listing file, obtain successfully and arrange key and custom algorithm decrypted list file acquisition listing file content according to both sides, different cipher modes according to section different in video segment listing file carry out obtaining different key, and corresponding video section is decrypted, final acquisition original video files, adds that to play queue etc. to be played.
The invention provides a kind of video-encryption device, comprising:
Transcoding module, for video to be encrypted is carried out consolidation form conversion, so that subsequent slice encryption;
Acquisition module, for obtaining all video datas corresponding to video file;
Choose module, for from the described all video frame images obtained, choose the key frame video file of some according to configuration file and slicing treatment is carried out to the file chosen, becoming video segment file to be encrypted;
Encrypting module, is encrypted for treating encrypted video section file;
Further, choose module described in comprise:
Choose unit, for choosing the key frame video file of some in all video frame images according to configuration file;
Processing unit: the key frame video file for choosing carries out segmentation slicing treatment, becomes video segment file to be encrypted.
Further, described encrypting module comprises:
Video-encryption unit, being encrypted at random according to pre-configured multiple cryptographic algorithm for treating encrypted video section file, obtaining the video segment listing file after encryption;
Key encryption unit, for utilizing secret key group to be encrypted to the video segment listing file after the encryption obtained.
Good effect of the present invention: the present invention compares traditional encryption technology, expends system resource low, little power consumption, is more suitable for the use of mobile device; CP (content supplier ContentProvider)/SP (service provider ServiceProvider) lower deployment cost is low, without the need to additional server and service software, can be better integrated with traditional cdn, configuration is simple, reduces deployment difficulty; All-network request all adopts http agreement, can firewall-penetrating, NAT, Router.The main prior art that still solves of the present invention is for service end source video file unprotect or the low problem of protection class in a word; considerably increase the fail safe of Internet communication curriculum video file; reduce the possibility of course piracy, effectively protect the intellectual property of network courses.
Accompanying drawing explanation
Fig. 1 is video-encryption flow chart in a kind of video encryption method of providing of the embodiment of the present invention 1;
Fig. 2 is key encryption flow chart in a kind of video encryption method of providing of the embodiment of the present invention 1;
Fig. 3 is secret key deciphering flow chart in a kind of decryption of video method of providing of the embodiment of the present invention 2;
Fig. 4 is decryption of video flow chart in a kind of decryption of video method of providing of the embodiment of the present invention 2;
Fig. 5 is the structural representation of a kind of video-encryption device that the embodiment of the present invention 3 provides.
Embodiment
Below in conjunction with accompanying drawing to a preferred embodiment of the present invention will be described in detail.
Embodiment 1
See figures.1.and.2, the preferred embodiment of the present invention 1 provides a kind of video encryption method, comprising:
First to needing the video file be encrypted to carry out consolidation form conversion, so that subsequent slice encryption;
Obtain all video frame images in video data corresponding to video file;
Key frame quantity is set by configuration file, chooses the key frame video file of some in all video frame images;
The key frame video file chosen is carried out segmentation slicing treatment, and the multiple encryption algorithms preset in random selecting configuration file is encrypted corresponding video segment file, and final acquisition encrypts rear video slice list file, and concrete steps are as follows:
First create video segment listing file, and create first video segment, and first video segment information is write described video segment listing file, random selecting encryption method, the data of first sliced section are encrypted;
Determine the original position of next video segment, video file is cut into slices, obtains second video segment, random selecting encryption method, the data of second sliced section are encrypted, afterwards the video segment information after encryption are write described video segment listing file;
Judge whether to arrive EOF position, if be less than, repeat previous step, until arrive end-of-file, obtain the video segment listing file including all videos slice information.
Utilize secret key group to be encrypted to the final video segment listing file obtained, ciphertext is supplied to decryption portion, and key encryption flow process is see Fig. 2.
Embodiment 2
With reference to Fig. 3 and Fig. 4, the preferred embodiment of the present invention 2 provides a kind of decryption of video method, comprising:
Player encrypted by Network Capture after video segment listing file, obtain successfully and arrange key and custom algorithm decrypted list file acquisition listing file content (secret key decryption portion according to both sides, see Fig. 3), different cipher modes according to section different in video segment listing file carry out obtaining different key, and (decryption of video part is decrypted to corresponding video section, see Fig. 4), final acquisition original video files, adds that to play queue etc. to be played.
Embodiment 3
With reference to Fig. 5, the preferred embodiment of the present invention 3 provides a kind of video-encryption device, comprising:
Transcoding module, for video to be encrypted is carried out consolidation form conversion, so that subsequent slice encryption;
Acquisition module, for obtaining all video datas corresponding to video file;
Choose module, for from the described all video frame images obtained, choose the key frame video file of some according to configuration file and slicing treatment is carried out to the file chosen, becoming video segment file to be encrypted, specifically comprise
Choose unit, for choosing the key frame video file of some in all video frame images according to configuration file;
Processing unit: the key frame video file for choosing carries out segmentation slicing treatment, becomes video segment file to be encrypted.
Encrypting module, being encrypted for treating encrypted video section file, specifically comprising:
Video-encryption unit, being encrypted at random according to pre-configured multiple cryptographic algorithm for treating encrypted video section file, obtaining the video segment listing file after encryption;
Key encryption unit, for utilizing secret key group to be encrypted to the video segment listing file after the encryption obtained.
Above-describedly be only the preferred embodiments of the present invention; be understood that; the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; the protection range be not intended to limit the present invention; all any amendments, equivalent replacement etc. made within thought of the present invention and principle, all should be included within protection scope of the present invention.