Summary of the invention
In order to solve the above technical problems, the present invention adopts the following technical solutions
A kind of the step of automatic identification encrypting and decrypting method for video data transmission, this method includes:
S1, the Transfer Parameters for obtaining video file to be transmitted confirm video file path to be transmitted and video to be transmitted text
The current state of part;
S2, according to user encryption or decryption instructions, encryption or decryption process is carried out to current video file to be transmitted;
S3, judge whether encryption or decryption process operation succeeds, and final mode of operation is returned into user, complete certainly
Dynamic identification cryptographic operation.
Preferably, the current state of the video file to be transmitted includes: to have encrypted, decrypted and untreated three kinds of shapes
State.
Preferably, the step S2 includes:
S21, encryption or decryption oprerations number maxCount, current crypto or decryption oprerations number count are attempted to maximum
Initializing set is carried out with the original state of video-encryption or decrypted result;
S22, pass through Rule of judgment: encrypting or whether decrypted state is operation failure state and current crypto or decryption number
Count is less than maximum trial encryption or decryption oprerations number maxCount, decides whether to attempt as video file to be transmitted
Encryption;If meeting Rule of judgment, S23 is thened follow the steps, if being unsatisfactory for Rule of judgment, thens follow the steps S3;
S23, for video file be arranged encryption or decryption oprerations operation mark, and judge operation mark setting whether at
Function, if success, thens follow the steps S24, if failure, it tries encryption or decryption oprerations number count add 1, and repeat step S22
And S23, until the Rule of judgment for identifying successfully or being unsatisfactory for step S22;
S24, according to user demand, the content for treating transmitting video files designated position carries out encryption or decryption oprerations;
S25, judge whether encryption or decryption oprerations succeed, if success, completes the encryption or solution of video file to be transmitted
Close operation, if failure, thens follow the steps S22 to S25, until the Rule of judgment for operating successfully or being unsatisfactory for step S22.
Preferably, the S24 includes:
S241, using 1024 byte of head of video file to be transmitted as encryption or decryption object;
S242, initial position is set as site=0;
S243, judge whether 1024 byte of head of current video file to be transmitted encrypts completion, if not completing, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are encrypted, if encryption is completed, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are decrypted;
S244, the data after encryption or decryption are written at site, are exited if writing failure;
S245,16 bytes, as site=site+16 are taken in 1024 byte again, and repeats step S243
To step S245, until 1024 byte data all complete by encryption or decryption.
Preferably, it if reading data failure or encryption/decryption failure in the step S243, directly exits.
Preferably, the step S3 includes:
If S31, encryption or decryption oprerations success, return to operation success status;
If S32, encryption or decryption oprerations failure, it tries roll back to video file and carry out the shape before encryption or decryption oprerations
State;
If the success of S33, rolling back action, returns operation failure state, if rolling back action fails, return can not restore shape
State.
A kind of automatic identification encrypting and decrypting system for video data transmission, the system include:
File identification unit obtains video file transfer request, confirms video file path to be transmitted and video to be transmitted
The current state of file;
Encryption unit carries out at encryption or decryption current video file to be transmitted according to user encryption or decryption instructions
Reason;
State feedback unit, judges whether encryption or decryption process operation succeeds, and final mode of operation is returned to
User completes automatic identification cryptographic operation.
Preferably, the current state of the video file to be transmitted includes: to have encrypted, decrypted and untreated three kinds of shapes
State.
Preferably, include: in the encryption unit
Initialization module attempts encryption or decryption oprerations number maxCount, current crypto or decryption oprerations time to maximum
The original state of number count and video-encryption or decrypted result carries out initializing set;
First judgment module passes through Rule of judgment: encrypting or whether decrypted state is operation failure state and current crypto
Or decryption number count is less than maximum trial encryption or decryption oprerations number maxCount, decides whether to attempt to be to be passed
Defeated video file encryption;If meeting Rule of judgment, the operation mark of encryption or decryption oprerations is set for video file, if discontented
Sufficient Rule of judgment then returns to the mode of operation that state feedback unit determines to user;
Operation mark setting module, the operation mark of encryption or decryption oprerations is arranged for video file, and judges operation mark
Know whether setting succeeds, if success, carries out user-specific content encryption or decryption oprerations, if failure, it tries encryption or solution
Close number of operations count adds 1, and repeats the operation of step first judgment module and operation mark setting module, until mark at
Until function or the Rule of judgment for being unsatisfactory for first judgment module;
Specified content processing module, according to user demand, the content for treating transmitting video files designated position is encrypted
Or decryption oprerations;
Second judgment module, judges whether encryption or decryption oprerations succeed, if success, completes video file to be transmitted
Encryption or decryption oprerations, if failure, execute first judgment module, operation mark setting module, specified content processing module and
The operation of second judgment module, until operating successfully or until being unsatisfactory for the Rule of judgment of first judgment module.
Preferably, the state feedback unit includes:
Encrypted result judgment module, if encryption or decryption oprerations success, return to operation success status, if encryption or decryption
Operation failure, it tries roll back to video file and carry out the state before encryption or decryption oprerations;
Rollback result judgment module, if rolling back action success, returns operation failure state, if rolling back action fails,
Return can not reset condition.
Beneficial effects of the present invention are as follows:
Technical solution of the present invention is run by method of calling, rather than interfacial type is manually operated, and facilitates system or program
It calls and executes.Increase encryption or decrypted state mark, system or program is facilitated to judge file encryption or decrypted state.Utilize we
Case generates library file, greatly reduces the memory space of the tool insert, greatly improves the speed of encryption and decryption.
Specific embodiment
In order to illustrate more clearly of the present invention, the present invention is done further below with reference to preferred embodiments and drawings
It is bright.Similar component is indicated in attached drawing with identical appended drawing reference.It will be appreciated by those skilled in the art that institute is specific below
The content of description is illustrative and be not restrictive, and should not be limited the scope of the invention with this.
As shown in Figure 1, the invention discloses a kind of automatic identification encrypting and decrypting method for video data transmission, the party
The step of method includes:
Step S1, the Transfer Parameters for obtaining video file to be transmitted, confirm video file path to be transmitted and view to be transmitted
The current state of frequency file;Wherein, the current state of the video file to be transmitted includes: to have encrypted, decrypted and untreated
Three kinds of states.Wherein, it needs to call two parameters in the step, the first parameter is video file path to be encrypted, and the second parameter is
Operating parameter, and indicated by following code:
Number 0 represents decryption, transmits this parameter, method video can be decrypted operation;
Number 1 represents encryption, transmits this parameter, and method can carry out cryptographic operation to video;
Number 2, which represents, obtains video file state, transmits this parameter, method only checks file current state, can return to three
Kind state, i.e. number 0 represent file and do not carry out any processing;Number 1 represents file and has encrypted;Number 2 represents file and has decrypted.
Step S2, according to user encryption or decryption instructions, encryption or decryption process is carried out to current video file to be transmitted.
Step S2 includes:
S21, encryption or decryption oprerations number maxCount, current crypto or decryption oprerations number count are attempted to maximum
Initializing set is carried out with the original state of video-encryption or decrypted result;
S22, pass through Rule of judgment: encrypting or whether decrypted state is operation failure state and current crypto or decryption number
Count is less than maximum trial encryption or decryption oprerations number maxCount, decides whether to attempt as video file to be transmitted
Encryption;If meeting Rule of judgment, S23 is thened follow the steps, if being unsatisfactory for Rule of judgment, thens follow the steps S3;
S23, for video file be arranged encryption or decryption oprerations operation mark, and judge operation mark setting whether at
Function, if success, thens follow the steps S24, if failure, it tries encryption or decryption oprerations number count add 1, and repeat step S22
And S23, until the Rule of judgment for identifying successfully or being unsatisfactory for step S22;
S24, according to user demand, the content for treating transmitting video files designated position carries out encryption or decryption oprerations;Its
In, as shown in Fig. 2, step S24 includes:
S241, using 1024 byte of head of video file to be transmitted as encryption or decryption object;
S242, initial position is set as site=0;
S243, judge whether 1024 byte of head of current video file to be transmitted encrypts completion, if not completing, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are encrypted, if encryption is completed, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are decrypted;If reading data in the step
Failure or encryption/decryption failure, then directly exit
S244, the data after encryption or decryption are written at site, are exited if writing failure;
S245,16 bytes, as site=site+16 are taken in 1024 byte again, and repeats step S243
To step S245, until 1024 byte data all complete by encryption or decryption;
S25, judge whether encryption or decryption oprerations succeed, if success, completes the encryption or solution of video file to be transmitted
Close operation, if failure, thens follow the steps S22 to S25, until the Rule of judgment for operating successfully or being unsatisfactory for step S22.
S3, judge whether encryption or decryption process operation succeeds, and final mode of operation is returned into user, complete certainly
Dynamic identification cryptographic operation.The step S3 includes:
If S31, encryption or decryption oprerations success, return to operation success status;
If S32, encryption or decryption oprerations failure, it tries roll back to video file and carry out the shape before encryption or decryption oprerations
State;
If the success of S33, rolling back action, returns operation failure state, if rolling back action fails, return can not restore shape
State.
This programme further discloses a kind of automatic identification encrypting and decrypting system for video data transmission, the system packet
It includes:
File identification unit obtains video file transfer request, confirms video file path to be transmitted and video to be transmitted
The current state of file has been encrypted, has been decrypted or untreated three kinds of states;
Encryption unit carries out at encryption or decryption current video file to be transmitted according to user encryption or decryption instructions
Reason;Include: in the encryption unit
Initialization module attempts encryption or decryption oprerations number maxCount, current crypto or decryption oprerations time to maximum
The original state of number count and video-encryption or decrypted result carries out initializing set;
First judgment module passes through Rule of judgment: encrypting or whether decrypted state is operation failure state and current crypto
Or decryption number count is less than maximum trial encryption or decryption oprerations number maxCount, decides whether to attempt to be to be passed
Defeated video file encryption;If meeting Rule of judgment, the operation mark of encryption or decryption oprerations is set for video file, if discontented
Sufficient Rule of judgment then returns to the mode of operation that state feedback unit determines to user;
Operation mark setting module, the operation mark of encryption or decryption oprerations is arranged for video file, and judges operation mark
Know whether setting succeeds, if success, carries out user-specific content encryption or decryption oprerations, if failure, it tries encryption or solution
Close number of operations count adds 1, and repeats the operation of step first judgment module and operation mark setting module, until mark at
Until function or the Rule of judgment for being unsatisfactory for first judgment module;
Specified content processing module, according to user demand, the content for treating transmitting video files designated position is encrypted
Or decryption oprerations;
Second judgment module, judges whether encryption or decryption oprerations succeed, if success, completes video file to be transmitted
Encryption or decryption oprerations, if failure, execute first judgment module, operation mark setting module, specified content processing module and
The operation of second judgment module, until operating successfully or until being unsatisfactory for the Rule of judgment of first judgment module.
State feedback unit, judges whether encryption or decryption process operation succeeds, and final mode of operation is returned to
User completes automatic identification cryptographic operation.The state feedback unit includes:
Encrypted result judgment module, if encryption or decryption oprerations success, return to operation success status, if encryption or decryption
Operation failure, it tries roll back to video file and carry out the state before encryption or decryption oprerations;
Rollback result judgment module, if rolling back action success, returns operation failure state, if rolling back action fails,
Return can not reset condition.
This programme can be write using C/C++ language, the dynamic base that can be called under system environments be generated, for video software
It calls.For example, the dynamic base so file that can be called under Android environment is generated, for the video software tune of Android environment
With.This programme such as uses conventional code to occupy storage size as 104k, if compiling generates library file and occupies memory space 30k
Left and right, is more suitable the quick calling of server or other associated video playout softwares.
Below by one group of embodiment, the present invention will be further described:
As shown in Figure 1, the present invention provides a kind of automatic identification encrypting and decrypting methods for video data transmission.The party
Specific step is as follows for method:
In step sl, the parameter for obtaining and handling transmitting, including need to encrypt or decrypt video file path, specific behaviour
It instructs;Wherein, concrete operations instruction is to check encryption and decryption state, cryptographic operation and the decryption oprerations of video file.If behaviour
Making instruction is to check the encryption and decryption state of video file, thens follow the steps S2.
State judgement can be carried out in S2 step to video file, return state, which have, have been encrypted, has decrypted and three kinds untreated
State.Encrypted state indicates that target video is encrypted state now, and need to be decrypted could normal browsing;Decrypted state table
Show that target video is decrypted state now, can be browsed;Untreated state indicates that the video was never carried out encrypting or be solved
Close operation.
If operational order is to encrypt or decrypt video video file, S3 is thened follow the steps.
S2 step can according to instruction to video file carry out encryption or decryption oprerations, operation after the completion of execute S3 return plus
As a result the implementing result of close/decryption oprerations is divided into encryption or successful decryption energy;Encryption or decryption failure, if encryption or decryption
Failure program can attempt state before rollback video file operation;Video file can not restore, after encryption or decryption failure, rollback
When operation similarly fails, the status indicator can be returned.When operational order is to encrypt or decrypt video file, step is executed
S3。
It is the local circulation encryption or decryption constructed by this programme for specifically encrypting or decrypting process in step S2
The specific execution step of method, this method includes:
S21, encryption or decryption oprerations number maxCount, current crypto or decryption oprerations number count are attempted to maximum
Initializing set is carried out with the original state of video-encryption or decrypted result;
S22, pass through Rule of judgment: encrypting or whether decrypted state is operation failure state and current crypto or decryption number
Count is less than maximum trial encryption or decryption oprerations number maxCount, decides whether to attempt as video file to be transmitted
Encryption;If meeting Rule of judgment, S23 is thened follow the steps, if being unsatisfactory for Rule of judgment, thens follow the steps S3;
S23, for video file be arranged encryption or decryption oprerations operation mark, and judge operation mark setting whether at
Function, if success, thens follow the steps S24, if failure, it tries encryption or decryption oprerations number count add 1, and repeat step S22
And S23, until the Rule of judgment for identifying successfully or being unsatisfactory for step S22;
S24, according to user demand, the content for treating transmitting video files designated position carries out encryption or decryption oprerations;
S25, judge whether encryption or decryption oprerations succeed, if success, completes the encryption or solution of video file to be transmitted
Close operation, if failure, thens follow the steps S22 to S25, until the Rule of judgment for operating successfully or being unsatisfactory for step S22.
The S24 includes:
S241, using 1024 byte of head of video file to be transmitted as encryption or decryption object;
S242, initial position is set as site=0;
S243, judge whether 1024 byte of head of current video file to be transmitted encrypts completion, if not completing, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are encrypted, if encryption is completed, from
The data of 16 bytes are taken out in 1024 bytes, and this 16 byte datas are decrypted;If reading data failure or adding
Close/decryption oprerations failure, then directly exit;
S244, the data after encryption or decryption are written at site, are exited if writing failure;
S245,16 bytes, as site=site+16 are taken in 1024 byte again, and repeats step S243
To step S245, until 1024 byte data all complete by encryption or decryption.
Be operation success status in state, or encrypted or decryption oprerations number be more than or equal to it is maximum attempt encryption or
S3 can be entered step after decryption oprerations number.
It can be done as follows in step S3 according to final result, when encryption or decryption oprerations success, return is operated successfully
State;After encryption or decryption oprerations failure, trial rolls back to state before video file operation, if success rollback, returns to behaviour
Make status of fail;If rolling back action also fails, return can not reset condition.
Whole video-encryption or decryption video file operation are completed.
Obviously, the above embodiment of the present invention be only to clearly illustrate example of the present invention, and not be pair
The restriction of embodiments of the present invention may be used also on the basis of the above description for those of ordinary skill in the art
To make other variations or changes in different ways, all embodiments can not be exhaustive here, it is all to belong to this hair
The obvious changes or variations that bright technical solution is extended out are still in the scope of protection of the present invention.