Embodiment
See also Fig. 1 to shown in Figure 4, a kind of network terminal control method for playing back based on AES and material checking of the present invention comprises the steps:
Step 1, the employed html file of ad content (or htm file), txt text and playlist xml file that the network terminal is play carry out the aes algorithm encryption by the platform end, the material that the ad content of network terminal broadcast is quoted is uploaded by the platform end, and appended the cryptographic check code at each material end;
Wherein, the described employed html file of ad content, txt text and the playlist xml file that the network terminal is play carries out aes algorithm by the platform end to be encrypted, and specifically comprises the steps:
Step 10, obtain the employed html file of ad content, txt text and playlist xml file at the platform end; These three files are operated by step 11 to step 18 one by one:
The length of step 11, calculation document obtains the file length value of the HEX form of 4 bytes, and inadequate 4 bytes of the length of file length value mend 0 in front; Surpass 4 bytes, remove the high byte that exceeds, keep the value of low 4 bytes;
The verification of step 12, calculation document and, obtain the checksum value of the HEX form of 4 bytes, checksum value is that all bytes with whole file obtain by accumulation calculating, inadequate 4 bytes of checksum value length mend 0 in front; Surpass 4 bytes, remove the high byte that exceeds, keep the value of low 4 bytes;
Step 13, obtain the alignment check value of file, obtain the alignment check value of the HEX form of 2 bytes, the alignment check value is by the first byte of checksum value and low 42 bytes that form of the second byte in high 4 and the step 12 of the first byte of step 11 File length value and the second byte;
Step 14, the threshold value A of the file length value in the step 11 and predefined 4 bytes of platform end (this threshold value A is 4 byte values of platform end and network terminal agreement) is carried out XOR (XOR) computing, operation result is changed into ASCII value B, this B is the character string of 8 bytes again;
Step 15, are 4 byte values of platform end and network terminal agreement with this threshold value of threshold value C(C of the checksum value in the step 12 and predefined 4 bytes of platform end) carry out XOR (XOR) computing, again operation result is changed into ASCII value D, this D is the character string of 8 bytes;
Step 16, the alignment check value in the step 13 is changed into ASCII value E, this E is the character string of 4 bytes;
Step 17, character string B, the D, the E that obtain in step 14, step 15, the step 16, form the character string F of 20 bytes with the BED order;
Step 18, the character string F in the step 17 is appended to the end of this document, and encrypts this document with aes algorithm.
The material that the ad content of network terminal broadcast is quoted is uploaded by the platform end, and appended the cryptographic check code at each material end, specifically comprise the steps:
Step 21, according to the material type that the platform end is uploaded, finding out needs material, i.e. picture file and video file; This picture file and video file are all operated by step 22 to step 29:
The length of step 22, calculation document; Obtain the file length value of the HEX form of 4 bytes, inadequate 4 bytes of the length of file length value mend 0 in front; Surpass 4 bytes, remove the high byte that exceeds, keep the value of low 4 bytes;
The CRC32 verification of step 23, calculation document; Obtain the check value of the HEX form of 2 bytes, this test value is to get this document front 1K byte to do the CRC32 verification with last 1K byte;
Step 24, obtain the alignment check value, obtain the alignment check value of the HEX form of 2 bytes; This alignment check value is by the first byte of CRC32 check value and low 42 bytes that form of the second byte in high 4 and the step 23 of the first byte of step 22 File length value and the second byte;
Step 25, the threshold value A of the file length value in the step 22 and described 4 bytes is carried out XOR, again operation result is changed into ASCII value H, this H is the character string of 8 bytes;
Step 26, the threshold value C of the check value in the step 23 and described 4 bytes is carried out XOR, again operation result is changed into ASCII value I, this I is the character string of 8 bytes;
Step 27, the alignment check value in the step 24 is changed into ASCII value J, this J is the character string of 4 bytes;
Step 28, character string H, the I, the J that obtain in step 25, step 26, the step 27, form the character string K of 20 bytes with the HJI order;
Step 29, the character string K in the step 28 is made aes algorithm encrypt, then be appended to the end of this document.
Step 2, platform end be by issuing download command to the network terminal, and inform that the network terminal downloads the path at required ftp server place,
Step 3, the network terminal obtain after described path resolves, and start the FTP thread and download html file, txt text and the playlist xml file after aes algorithm is encrypted and carry out the end and append each material after the cryptographic check code is processed; (this playlist xml file is the strategy file of network terminal control media play, this document has recorded material path and other property values of the time span of material broadcast and strategy that task is switched etc. of quoting in the network terminal playing process, the network terminal is when downloading the material process and calling playlist xml file broadcast media task, all needing to decipher first playlist xml file and verification identifying code) network terminal is when broadcasting advertisement content, to the html file after encrypting, txt text and playlist xml file are decrypted, and each material of quoting in the ad content is verified;
Step 4, when deciphering html file, txt text and playlist xml file, any file decryption is wrong or the checking material is wrong, then the network terminal will forbid playing this wrong file or wrong material; And reporting the platform end, corresponding wrong file or material are downloaded in request again.
Wherein, the described network terminal is decrypted html file, txt text and playlist xml file after encrypting when broadcasting advertisement content, specifically comprises the steps:
Step 31, the network terminal obtain each file of download, and judge whether each file type of downloading is html file, txt text or playlist xml file; That each file that then will download operates according to step 32 to step 38 one by one, and is no, then do not operate;
Step 32, the file of downloading with aes algorithm deciphering;
Step 33, extraction this document end 20 bytes, and resolve into three parts, first is 8 bytes in front in 20 bytes, and this character string is changed into the value L of the HEX form of 4 bytes; Second portion is middle 4 bytes in 20 bytes, and the character string of middle 4 bytes is changed into the value M of the HEX form of 2 bytes; Third part is last 8 bytes in 20 bytes, and character string that will these last 8 bytes changes into the value N of the HEX form of 4 bytes;
Step 34, the L that obtains in the step 33 and the threshold value A of described 4 bytes are carried out XOR, obtain as a result O; The N that obtains in the step 33 and the threshold value C of described 4 bytes are carried out XOR, obtain as a result P;
The first byte and the second byte high 4 and extract the first byte and the second byte among the P low 4 among the O forms the Q value of 2 bytes in step 35, the extraction step 34;
Whether step 36, comparison M value and Q value equate, if equate, then continue step 37; If unequal, then forbid broadcasting advertisement content, and report the alignment verification of platform end file to make mistakes that request re-issues this document;
Step 37, remove 20 bytes of end of file after, calculate length R and verification and the S of this document;
Whether R equals O in step 38, the determining step 37, and whether S equals P; The two all equates, then continues the material checking, if one of them does not wait or the two is all unequal, then forbids broadcasting advertisement content, and reports the bad checksum of platform end file, asks to re-issue this document.
The network terminal generally speaking hardware resource is all relatively nervous, especially processes relatively large material file, such as video file and picture file.Therefore, calculate the check value of picture and video, just do not adopt the in full cumulative and algorithm of byte, but directly obtain this document head 1K byte and last 1K byte, then make CRC32 algorithm calculation check value.So just can shorten to a great extent the CPU processing time, improve running efficiency of system.In the present invention, each material of quoting in the ad content is verified, comprised the steps: that specifically step 41, the file relative path that provides according to play list file obtain material in this locality, i.e. picture file or video file;
The character string of step 42,20 bytes in extraction document end, and decipher first with aes algorithm, then resolve into three parts, first is 8 bytes in front in 20 bytes, and this character string is changed into the value T of the HEX form of 4 bytes; Second portion is middle 4 bytes in 20 bytes, and the character string of middle 4 bytes is changed into the value U of the HEX form of 2 bytes; Third part is last 8 bytes in 20 bytes, and the character string of last 8 bytes is changed into the value V of the HEX form of 4 bytes;
Step 43, the T that obtains in the step 42 and the threshold value A of described 4 bytes are carried out XOR, obtain as a result W; The V that obtains in the step 42 and the threshold value C of described 4 bytes are carried out XOR, obtain as a result X;
The first byte and the second byte high 4 and extract the first byte and the second byte among the X low 4 among the W forms the Y value of 2 bytes in step 44, the extraction step 43;
Whether step 45, comparison U value and Y value equate, if equate, then continue step 46; If unequal, then forbid broadcasting advertisement content, and report the alignment verification of platform end picture file or video file to make mistakes that request re-issues this document;
Step 46, remove 20 bytes of end of file after, calculate length Z and the CRC32 check value AB of this document, this check value AB does the CRC32 computing and obtains for getting file header 1K byte and end 1K byte;
Whether Z equals W in step 47, the determining step 46, and whether AB equals X; The two is all equal, then, and broadcasting advertisement content; If one of them does not wait or the two is all unequal, then forbid broadcasting advertisement content, and report platform end picture file or video file bad checksum that request re-issues this document.
Here it is worth mentioning that:
1, platform end encrypted authentication html(or htm) file, txt text, playlist xml file,
The platform end is according to the file of uploading, determine whether html(or htm) file, txt text, playlist xml file, in the situation of these files, the file structure that final operation obtains is respectively such as table 1:html(or htm) file structure, table 2:txt text structure, table 3 playlist xml file structure:
Table 1
The html file |
8 byte file length |
4 byte-aligned test values |
8 byte file verifications and |
Table 2
The txt text |
8 byte file length |
4 byte-aligned test values |
8 byte file verifications and |
Table 3
Playlist xml file |
8 byte file length |
4 byte-aligned test values |
8 byte file verifications and |
Wherein: 8 byte file length namely are the ascii strings of 8 bytes, are character string B;
4 byte-aligned test values also are ascii strings, are character string E;
8 byte file verifications and also be ascii string are character string D.
2, platform end encrypted authentication picture file, video file
The platform end determines whether picture file, video file according to the file of uploading, and is in the situation of these files, and the file structure that final operation obtains is respectively such as table 4: picture file structure, table 5: video file structure.
Table 4
Picture file |
8 byte file length |
4 byte-aligned test values |
8 byte CRC32 check values |
Table 5
Video file |
8 byte file length |
4 byte-aligned test values |
8 byte CRC32 check values |
Wherein: 8 byte file length namely are the ascii strings of 8 bytes, are character string H;
The alignment test value of 4 bytes also is ascii string, is character string J;
8 byte CRC32 check values also are ascii strings, are character string I.
In a word, consider based on total system, especially for the relatively nervous embedded system of hardware resources, proposed a kind of novel encryption and verification algorithm.This algorithm is divided into the dual mode processing with the data of media bearer, and a kind of is full text to be carried out AES encrypt, and another kind is that the AES encryption is done at certain position in the extraction data.The effective combination of the two on the operational efficiency of the fail safe of data content and system, is found a metastable balance point, also is well positioned to meet Information Security that the current device merchant proposes and the requirement of uniqueness.And it has reduced the cost that uses encryption in the product largely, improves product market competitiveness, and shortens to a great extent the processing time of the network terminal, also can guarantee integrality and the uniqueness of material file.
The above only is preferred embodiment of the present invention, and all equalizations of doing according to the present patent application claim change and modify, and all should belong to covering scope of the present invention.