CN114143014A - Media file encryption method, decryption method, transmission method, device and system - Google Patents
Media file encryption method, decryption method, transmission method, device and system Download PDFInfo
- Publication number
- CN114143014A CN114143014A CN202010808494.1A CN202010808494A CN114143014A CN 114143014 A CN114143014 A CN 114143014A CN 202010808494 A CN202010808494 A CN 202010808494A CN 114143014 A CN114143014 A CN 114143014A
- Authority
- CN
- China
- Prior art keywords
- bits
- value
- sub
- code
- encrypted
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 62
- 230000005540 biological transmission Effects 0.000 title claims abstract description 13
- 238000004590 computer program Methods 0.000 claims description 10
- 238000012546 transfer Methods 0.000 claims description 3
- 230000008520 organization Effects 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 21
- 230000008569 process Effects 0.000 description 6
- 230000006870 function Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000001737 promoting effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Storage Device Security (AREA)
Abstract
The disclosure discloses a media file encryption method, a media file decryption method, a media file transmission method, a media file encryption device, a media file decryption device, a media file transmission device and a media file encryption system, and relates to the field of encryption and decryption. The method comprises the following steps: splitting the code of the source media file according to 2N bits to obtain a plurality of sub-codes; taking the value corresponding to the last N bits of the sum of the values corresponding to the front and the back N bits of each sub-code as the first encrypted value of the sub-code, and taking the absolute value of the difference of the values corresponding to the front and the back N bits as the second encrypted value of the sub-code; and setting a first identifier and a second identifier at a preset position of each sub-code to obtain an encrypted value of each sub-code, and combining the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file. The risk of decryption caused by the leakage of the secret key of the media file is prevented, and meanwhile, the newly inserted identification breaks the sequential organization structure of the original media file, and the media file is guaranteed to be difficult to crack.
Description
Technical Field
The present disclosure relates to the field of encryption and decryption, and in particular, to a media file encryption method, decryption method, transmission method, device, and system.
Background
In the field of audio file transmission, when a client requests a server to transmit an audio file, the server generally needs to encrypt the transmitted file in order to protect the file from being stolen, and the client receives the audio file transmitted by the server, decrypts the audio file and plays the audio file.
In the related art, a streaming encryption algorithm with too single key and algorithm, or a complete encryption algorithm and a layered encryption algorithm with high operation complexity is usually adopted, and when the key is leaked, the audio file is at risk of being decrypted.
Disclosure of Invention
One technical problem to be solved by the present disclosure is to provide a media file encryption method, a decryption method, a transmission method, an apparatus and a system, which can prevent the risk of decrypting a media file due to key leakage.
According to an aspect of the present disclosure, a media file encryption method is provided, including: splitting the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer; for each sub-code, taking the value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as a first encryption value of the sub-code, and taking the absolute value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second encryption value of the sub-code; setting a first identifier and a second identifier at a preset position of each sub-code, wherein the first identifier is configured to identify whether the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is larger than an overflow threshold value, and the second identifier is configured to identify whether the difference between the values corresponding to the first N bits and the values corresponding to the last N bits is larger than or equal to 0; determining the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier; and combining the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file.
In some embodiments, the overflow threshold is a maximum value corresponding to N bits.
In some embodiments, the first cryptographic value is a cryptographic value of the first N bits, wherein, when the sum is greater than the overflow threshold, the difference between the sum of the value corresponding to the first N bits and the value corresponding to the last N bits and the overflow threshold is subtracted by 1 as the cryptographic value of the first N bits of the sub-code; and when the sum is less than or equal to the overflow threshold, taking the sum of the values corresponding to the first N bits and the values corresponding to the last N bits as the encryption value of the first N bits of the sub-code.
In some embodiments, the second cryptographic value is a cryptographic value of the last N bits, wherein, when the difference is greater than or equal to 0, the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is taken as the cryptographic value of the last N bits of the sub-encoding; and when the difference is smaller than 0, taking the negative value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as the encryption value of the last N bits of the sub-code.
In some embodiments, the first and second identifiers are represented by 1/2 × N-bit values, respectively, where N is an even number.
According to another aspect of the present disclosure, a media file decryption method is further provided, including: splitting the code of the encrypted media file according to every other first identifier and second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether the sum of the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the last N bits of each sub-code is greater than an overflow threshold, and the second identifier is configured to identify whether the difference between the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the last N bits of each sub-code is greater than or equal to 0; removing the first identifier and the second identifier of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code; determining the decrypted values of the first N bits and the second N bits of each sub-code according to the first identifier and the second identifier and the first encrypted value and the second encrypted value of each encrypted sub-code; determining the value of each sub-code according to the decrypted values of the first N bits and the decrypted values of the last N bits of each sub-code; and combining the values of the plurality of sub-codes to obtain the code of the source media file.
In some embodiments, the overflow threshold is a maximum value corresponding to N bits.
In some embodiments, the first cryptographic value is a cryptographic value of the first N bits and the second cryptographic value is a cryptographic value of the last N bits, wherein if the first flag is that the sum of the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits is greater than the overflow threshold, then the sum of the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to + 1; and if the first identification is that the sum of the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits is less than or equal to the overflow threshold, the sum of the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits of the sub-code is equal to the encrypted value of the first N bits.
In some embodiments, the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value, wherein if the second identifier is that the difference between the decrypted value corresponding to the first N bits of the sub-code and the decrypted value corresponding to the second N bits is greater than or equal to 0, then the difference between the decrypted value corresponding to the first N bits of the encrypted sub-code and the decrypted value corresponding to the second N bits is equal to the second N-bit cryptographic value; and if the second identification is that the difference between the decryption values corresponding to the first N bits of the sub-code and the decryption values corresponding to the last N bits is less than 0, the difference between the decryption values of the first N bits of the encrypted sub-code and the decryption values of the last N bits is equal to the negative value of the encryption values of the last N bits.
According to another aspect of the present disclosure, a media file transmission method is further provided, including: the encryption device splits the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer; the encryption device takes the value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as a first encryption value of each sub-code, and takes the absolute value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second encryption value of each sub-code; the encryption device sets a first identifier and a second identifier at a preset position of each sub-code, wherein the first identifier is configured to identify whether the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is larger than an overflow threshold value, and the second identifier is configured to identify whether the difference between the values corresponding to the first N bits and the values corresponding to the last N bits is larger than or equal to 0; the encryption device determines the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code, the first identifier and the second identifier, combines the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file, and sends the code of the encrypted media file to the decryption equipment; the decryption device splits the code of the encrypted media file according to every other first identifier and every other second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier; the decryption device removes the first identification and the second identification of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code; the decryption device determines the decrypted values of the first N bits and the second N bits of each sub-code according to the first identifier and the second identifier and the first encrypted value and the second encrypted value of each encrypted sub-code; and the decryption device determines the value of each sub-code according to the decryption value of the first N bits and the decryption value of the last N bits of each sub-code, and combines the values of the plurality of sub-codes to obtain the code of the source media file.
According to another aspect of the present disclosure, there is also provided a media file encryption apparatus, including: the source file splitting unit is configured to split the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer; an encrypted value generating unit configured to, for each sub-code, take a value corresponding to last N bits of a sum of a value corresponding to the first N bits and a value corresponding to the last N bits as a first encrypted value of the sub-code, and take an absolute value of a difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second encrypted value of the sub-code; an identifier setting unit configured to set a first identifier and a second identifier at a predetermined position of each sub-code, wherein the first identifier is configured to identify whether a sum of values corresponding to the first N bits and values corresponding to the last N bits is greater than an overflow threshold, and the second identifier is configured to identify whether a difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0; and the encrypted file generating unit is configured to determine the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier, and combine the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file.
According to another aspect of the present disclosure, there is also provided a media file decryption apparatus, including: the encrypted file splitting unit is configured to split the code of the encrypted media file according to every other first identifier and every other second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether the sum of the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the last N bits of each sub-code is greater than an overflow threshold value, and the second identifier is configured to identify whether the difference between the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the N bits of each sub-code after decryption is greater than or equal to 0; the identification deleting unit is configured to remove the first identification and the second identification of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code; a sub-code decryption unit configured to determine a decrypted value of the first N bits and a decrypted value of the last N bits of each sub-code according to the first identifier and the second identifier, and the first encrypted value and the second encrypted value of each encrypted sub-code, and determine a value of each sub-code according to the decrypted value of the first N bits and the decrypted value of the last N bits of each sub-code; and the source file generating unit is configured to combine the values of the plurality of sub-codes to obtain the code of the source media file.
According to another aspect of the present disclosure, there is also provided a media file encryption and decryption system, including: the above media file encryption device; and the media file decryption device.
According to another aspect of the present disclosure, there is also provided an electronic device, including: a memory; and a processor coupled to the memory, the processor configured to execute the media file encryption method as described above, or the media file decryption method as described above, or the media file transmission method as described above, based on instructions stored in the memory.
According to another aspect of the present disclosure, there is also provided a non-transitory computer-readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement a media file encryption method as described above, or a media file decryption method as described above, or a media file transmission method as described above.
In the embodiment of the disclosure, the media file is encrypted by using a mathematical formula and a form of changing the structure of the media file, the encryption process has no key to participate in the encryption, the risk of decrypting the media file due to key leakage is prevented, and meanwhile, the newly inserted identifier breaks through the sequential organization structure of the original media file, and the media file is ensured to be difficult to crack.
Other features of the present disclosure and advantages thereof will become apparent from the following detailed description of exemplary embodiments thereof, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description, serve to explain the principles of the disclosure.
The present disclosure may be understood more clearly and in accordance with the following detailed description, taken with reference to the accompanying drawings,
wherein:
fig. 1 is a flow diagram of some embodiments of a media file encryption method of the present disclosure.
Fig. 2 is a flowchart illustrating a media file encryption method according to another embodiment of the disclosure.
Fig. 3 is a flow chart illustrating some embodiments of a media file decryption method of the present disclosure.
Fig. 4 is a flow diagram of some embodiments of a media file transfer method of the present disclosure.
Fig. 5 is a flowchart illustrating a media file transmission method according to another embodiment of the disclosure.
Fig. 6 is a schematic structural diagram of some embodiments of a media file encryption apparatus according to the present disclosure.
Fig. 7 is a schematic structural diagram of some embodiments of a media file decryption apparatus according to the present disclosure.
Fig. 8 is a schematic structural diagram of some embodiments of a media file decryption system of the present disclosure.
Fig. 9 is a schematic structural diagram of some embodiments of an electronic device of the present disclosure.
Fig. 10 is a schematic diagram of source media file encoding and splitting according to the present disclosure.
Detailed Description
Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components and steps, the numerical expressions, and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the disclosure, its application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
For the purpose of promoting a better understanding of the objects, aspects and advantages of the present disclosure, reference is made to the following detailed description taken in conjunction with the accompanying drawings.
Fig. 1 is a flow diagram of some embodiments of a media file encryption method of the present disclosure.
In step 110, the code of the source media file is split according to 2N bits to obtain a plurality of sub-codes, where N is a positive integer.
In some embodiments, the source media file is an audio file.
In some embodiments, the value of N is determined based on the format of the source media file. For example, if the audio file is in an 8k 16-bit format, the coding of the audio file may be split according to 2 bytes, i.e., every 16 bits, to obtain a plurality of sub-codes, where N is 8 bits, i.e., 1 byte.
In step 120, for each sub-code, the value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits is used as the first encrypted value of the sub-code, and the absolute value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is used as the second encrypted value of the sub-code.
In some embodiments, the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value. It will be appreciated by those skilled in the art that the first cryptographic value may also be a cryptographic value of the last N bits and the second cryptographic value may be a cryptographic value of the first N bits, as long as the encryption apparatus and the decryption apparatus agree.
In some embodiments, when the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is greater than the overflow threshold, the difference between the sum of the values corresponding to the first N bits and the values corresponding to the last N bits and the overflow threshold is subtracted by 1 as the encrypted value of the first N bits of the sub-code.
In some embodiments, the overflow threshold is the maximum value of the binary corresponding to the N bits. For example, if N is 8, the overflow threshold is 11111111, and FF is expressed as a hexadecimal number. If the value corresponding to the first 8 bits of a sub-code is 00000001 and the value corresponding to the last 8 bits is 00000010, the sum of the values of the first 8 bits and the last 8 bits of the sub-code is 00000011, and is not greater than the overflow threshold 11111111111. If the value corresponding to the first 8bit of a certain sub-code is 11111111 and the value corresponding to the last 8bit is 00000001, the sum of the values of the first 8bit and the last 8bit of the sub-code is 100000000, and the overflow threshold is exceeded.
For example, if the first 8 bits of a sub-code correspond to a value of 11111111 and the last 8 bits correspond to a value of 00000001, the encryption value of the first 8 bits of the sub-code is 00000000.
In some embodiments, when the sum of the value corresponding to the first N bits and the value corresponding to the last N bits is less than or equal to the overflow threshold, the sum of the value corresponding to the first N bits and the value corresponding to the last N bits is used as the encrypted value of the first N bits of the sub-code.
For example, if the value corresponding to the first 8 bits of a sub-code is 00000001, and the value corresponding to the last 8 bits is 00000010, the encrypted value of the first 8 bits of the sub-code is 00000011.
In some embodiments, when the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is greater than or equal to 0, the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is taken as the encrypted value of the last N bits of the sub-code.
For example, if the value corresponding to the first 8 bits of a sub-code is 00000010, and the value corresponding to the last 8 bits is 00000001, the encrypted value of the last 8 bits of the sub-code is 00000001.
In some embodiments, when the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is less than 0, the negative value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is taken as the encrypted value of the last N bits of the sub-code.
For example, if the value corresponding to the first 8 bits of a sub-code is 00000001, and the value corresponding to the last 8 bits is 00000010, the encrypted value of the last 8 bits of the sub-code is 00000001.
In some embodiments, a formula is utilizedCalculating the first N bits of encryption value and the last N bits of encryption value of each sub-code, wherein f (x, y) is the sub-code, x is the first N bits of encryption value, and y is the last N bits of encryption value. When x + y is greater than the overflow threshold, the cryptographic value of the first N bits is z1When the difference value with the overflow threshold value is minus 1 and x + y is less than or equal to the overflow threshold value, the encryption value of the first N bits is z1. When x-y is greater than or equal to 0, the encryption value of the last N bits is z2When x-y is less than 0, the cryptographic value of the last N bits is-z2I.e. the cryptographic value of the last N bits is | z2|。
In step 130, a first flag and a second flag are set at a predetermined position of each sub-code, wherein the first flag is configured to identify whether the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is greater than an overflow threshold, and the second flag is configured to identify whether the difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0.
In some embodiments, the first and second identifiers are represented by 1/2 × N-bit values, respectively, where N is an even number. For example, when the sum of the values of the first 8bit and the last 8bit of a certain sub-code is greater than 11111111111, the first flag is 0001; when the sum of the values of the front 8bit and the rear 8bit of the sub-code is less than or equal to 11111111111, the first mark is 0000; when the difference value of the front 8bit and the rear 8bit of the sub-code is more than or equal to 0, the first mark is 0000; when the difference between the values of the first 8bit and the last 8bit of the sub-code is less than 0, the first identifier is 0001.
In step 140, the cryptographic value of each sub-code is determined based on the first cryptographic value, the second cryptographic value and the first identifier, the second identifier of each sub-code.
In some embodiments, each sub-encoded cryptographic value is represented by a combination of the first cryptographic value + the second cryptographic value + the first identity + the second identity. For example, if the first 8bit encryption value of a sub-code is 00000001, the second 8bit encryption value is 00000010, the first identifier is 0000, and the second identifier is 0001, then the encryption value of the sub-code is 000000010000001000000001.
In step 150, the encoded values of the plurality of sub-encodings are combined to obtain an encoding of the encrypted media file.
In some embodiments, the encoded values of the plurality of sub-encodings are combined in the order of the encoding split of the source media file to obtain the encoding of the encrypted media file.
In the embodiment, the media file is encrypted by using a mathematical formula and a form of changing the structure of the media file, the encryption is not performed by using a key in the process, the risk of decrypting the media file due to the leakage of the key of the media file is prevented, and meanwhile, the newly inserted identifier breaks through the sequential organization structure of the original media file, so that the media file is ensured to be difficult to crack.
Fig. 2 is a flowchart illustrating a media file encryption method according to another embodiment of the disclosure. In this embodiment, the media file is described by taking an audio file as an example. A first flag indicating that the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is larger than 11111111 is 0001, a first flag indicating that the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not more than 11111111 is 0000, a second flag indicating that the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not less than 0 is 0000, and a second flag indicating that the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not more than 0 is 0001.
In step 210, the code of the source audio file is divided by 2 bytes to obtain a plurality of sub-codes.
For example, as shown in fig. 10, the encoding of the source audio file is split from the header, and each adjacent two bytes are split into one sub-encoding. If the encoding of the source audio file is represented in binary, such as 11001100011101001100101001010101, the encoding of the source audio file is split into 1100110001110100 and 1100101001010101.
In step 220, the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte and the difference of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte of each sub-code are calculated.
For example, byte 1 corresponds to a value of x, byte 2 corresponds to a value of y, then x + y is calculated, and x-y is calculated.
In step 230, it is determined whether the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is greater than 11111111, if so, step 231 is executed, otherwise, step 232 is executed.
In step 231, the value of the last 8 bits of the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is used as the encrypted value of the 1 st byte, and the first identifier 0001 is inserted after the 2 nd byte.
In step 232, the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is used as the encrypted value of the 1 st byte, and the first identifier 0000 is inserted after the 2 nd byte.
In step 240, it is determined whether the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is greater than or equal to 0, if yes, step 241 is executed, otherwise, step 242 is executed.
In step 241, the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is used as the encrypted value of the 2 nd byte, and the second identifier 0000 is inserted after the first identifier.
In step 242, the negative value of the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is used as the encrypted value of the 2 nd byte, and the second identifier 0001 is inserted after the first identifier.
In some embodiments, a formula is utilizedWherein, when x + y is larger than 11111111, the encryption value of the 1 st byte is z111111111-1. When x-y is more than or equal to 00000000, the encryption value of the 2 nd byte is z2When x-y is less than 00000000, the encryption value of the 2 nd byte is-z2。
In some embodiments, the encrypted value of the 1 st byte and the encrypted value of the 2 nd byte are 10-ary numbers.
In step 250, the combination of the encrypted value of the 1 st byte, the encrypted value of the 2 nd byte, the first identifier and the second identifier is used as the encrypted value of each sub-code.
In step 260, the encrypted values of the plurality of sub-codes are combined according to the code splitting order of the source media file to obtain the code of the encrypted media file.
In the above embodiment, for the original audio file, starting from the file header, each adjacent two bytes are split into a pair of unknown numbers x and y, then the encrypted value of each byte is calculated, and the identifier is added after the two bytes, so that the subsequent decryption device can decrypt the original audio file according to the identifier, and the security of the original audio file is ensured.
Fig. 3 is a flow chart illustrating some embodiments of a media file decryption method of the present disclosure.
In step 310, the encoding of the encrypted media file is split every other first identifier and second identifier to obtain a plurality of encrypted sub-encodings, where each encrypted sub-encoding corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether a sum of a value corresponding to a first N bits of each sub-encoding and a value corresponding to a second N bits of each sub-encoding is greater than an overflow threshold, and the second identifier is configured to identify whether a difference between a value corresponding to a first N bits of each sub-encoding and a value corresponding to a second N bits of each sub-encoding is greater than or equal to 0.
In some embodiments, the media file is an audio file.
In some embodiments, the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value.
In some embodiments, the first and second identifiers are represented by 1/2 × N-bit values, respectively, where N is an even number.
For example, if the audio file is split according to 2 bytes during encryption, and the first identifier and the second identifier occupy 1 byte in total, the encrypted audio file is divided according to every 3 bytes. The 3 rd byte corresponds to the first identifier and the second identifier, the first encrypted value is the encrypted value of the 1 st byte of the sub-code, and the second encrypted value is the encrypted value of the 2 nd byte of the sub-code.
In step 320, the first identifier and the second identifier of each encrypted sub-code are removed to obtain the first encrypted value and the second encrypted value of each encrypted sub-code.
In step 330, the first N-bit value and the last N-bit value of each sub-code are determined based on the first identifier and the second identifier and the first cryptographic value and the second cryptographic value of each encrypted sub-code.
For example, if the first flag indicates that the sum of the values corresponding to the first N bits of the sub-code and the values corresponding to the last N bits is greater than the overflow threshold, the sum of the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to + 1; and if the first identification is that the sum of the values corresponding to the first N bits and the values corresponding to the last N bits of the sub-code is less than or equal to the overflow threshold, the sum of the decrypted values of the first N bits and the decrypted values of the last N bits of the encrypted sub-code is equal to the encrypted value of the first N bits.
For another example, if the second identifier is that the difference between the values corresponding to the first N bits of the sub-code and the values corresponding to the second N bits is greater than or equal to 0, the difference between the decrypted value of the first N bits of the encrypted sub-code and the decrypted value of the second N bits is equal to the encrypted value of the second N bits; and if the second identifier is that the difference between the values corresponding to the first N bits of the sub-code and the values corresponding to the last N bits is less than 0, the difference between the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to the negative value of the encrypted values of the last N bits.
I.e. according to the formulaSolving x and y, wherein x is the encrypted value of the first N bits, y is the encrypted value of the last N bits, and the decryption device determines the first encrypted value as z according to the first identifier and the second identifier1Again, at z is required1On the basis of the difference from the overflow threshold minus 1, and determining the second cryptographic value as z2Is also-z2。
At step 340, a value for each sub-code is determined based on the values of the first N bits and the values of the last N bits of each sub-code.
In some embodiments, each sub-coded value is a combination of the first N bits of the value and the last N bits of the value.
In step 350, the values of the plurality of sub-encodings are combined to obtain an encoding of the source media file.
In some embodiments, the values of the plurality of sub-encodings are combined in the encoding split order of the encrypted media file to obtain the encoding of the source media file.
In the above embodiment, the decryption device calculates the actual value of each sub-code according to the first identifier and the second identifier, and further obtains the code of the source media file.
Fig. 4 is a flowchart illustrating a media file decryption method according to another embodiment of the disclosure. In this embodiment, the media file is described by taking an audio file as an example. A first flag indicating that the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is larger than 11111111 is 0001, a first flag indicating that the sum of the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not more than 11111111 is 0000, a second flag indicating that the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not less than 0 is 0000, and a second flag indicating that the difference between the value corresponding to the 1 st byte and the value corresponding to the 2 nd byte is not more than 0 is 0001.
At step 410, the code of the encrypted audio file is divided by 3 bytes to obtain a plurality of encrypted subcodes.
In step 420, for each encrypted sub-code, it is determined whether the first identifier is 0000, if so, step 421 is performed, otherwise, step 422 is performed.
In step 421, the sum of the decrypted value of the 1 st byte and the decrypted value of the 2 nd byte of the formula is established as the encrypted value of the 1 st byte.
In step 422, the sum of the decrypted value of the 1 st byte and the decrypted value of the 2 nd byte of the formula is established as the encrypted value of the 1 st byte +11111111+ 00000001.
In step 430, it is determined whether the second identifier is 0000 for each encrypted sub-code, if so, step 431 is performed, otherwise, step 432 is performed.
In step 431, the difference between the decrypted value of the 1 st byte and the decrypted value of the 2 nd byte of the formula is established as the encrypted value of the 2 nd byte.
At step 432, the difference between the decrypted value of the 1 st byte and the decrypted value of the 2 nd byte of the formula is established as the negative value of the encrypted value of the 2 nd byte.
At step 440, the formula is solved to obtain the decrypted value of the 1 st byte and the decrypted value of the 2 nd byte.
In step 450, the combination of the 1 st byte decrypted value and the 2 nd byte decrypted value is taken as each sub-encoded decrypted value.
At step 460, the decrypted values of the plurality of sub-codes are combined according to the encoding splitting order of the encrypted audio file to obtain the encoding of the source audio file.
In the above embodiment, when the encrypted audio file is decrypted, every three bytes of the encrypted audio file are divided into a group, and a solution formula is established according to the first identifier and the second identifier to obtain the decryption value of the 1 st byte and the decryption value of the 2 nd byte of each sub-code, so as to obtain the code of the source audio file. The decryption process does not need to use a key, and the risk that the audio file is obtained and decrypted due to key leakage is reduced.
Fig. 5 is a flow diagram of some embodiments of a media file transfer method of the present disclosure.
In step 510, the encryption apparatus splits the code of the source media file according to 2N bits to obtain a plurality of sub-codes, where N is a positive integer.
In step 520, the encryption apparatus uses, for each sub-code, a value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as a first encrypted value of the sub-code, and uses an absolute value of a difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second encrypted value of the sub-code.
In some embodiments, the first cryptographic value is a cryptographic value corresponding to the first N bits, and the second cryptographic value is a cryptographic value corresponding to the first N bits.
In step 530, the encryption apparatus sets a first flag and a second flag at a predetermined position of each sub-code, wherein the first flag is configured to identify whether a sum of values corresponding to the first N bits and values corresponding to the last N bits is greater than an overflow threshold, and the second flag is configured to identify whether a difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0.
In step 540, the encryption apparatus determines the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code, the first identifier and the second identifier, combines the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file, and sends the code of the encrypted media file to the decryption device.
In some embodiments, the encrypted value corresponding to the first N bits, the encrypted value corresponding to the last N bits, the first identifier and the second identifier of each sub-code are combined in sequence to obtain the encrypted value of each sub-code, and then the encrypted values of the plurality of sub-codes are combined to obtain the code of the encrypted media file.
In step 550, the decryption device splits the code of the encrypted media file according to every other first identifier and every other second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier.
In step 560, the decryption apparatus removes the first identifier and the second identifier of each encrypted sub-code to obtain the first encrypted value and the second encrypted value of each encrypted sub-code.
In step 570, the decryption device determines the first N bits of value and the last N bits of value for each sub-code based on the first identifier and the second identifier and the first encrypted value and the second encrypted value for each encrypted sub-code.
In some embodiments, if the first flag indicates that the sum of the values corresponding to the first N bits of the sub-code and the values corresponding to the last N bits is greater than the overflow threshold, the sum of the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to + 1; and if the first identification is that the sum of the values corresponding to the first N bits and the values corresponding to the last N bits of the sub-code is less than or equal to the overflow threshold, the sum of the decrypted values of the first N bits and the decrypted values of the last N bits of the encrypted sub-code is equal to the encrypted value of the first N bits.
In some embodiments, if the second identifier is that the difference between the decrypted value corresponding to the first N bits of the sub-code and the decrypted value corresponding to the last N bits is greater than or equal to 0, the difference between the decrypted value of the first N bits of the encrypted sub-code and the decrypted value of the last N bits is equal to the encrypted value of the last N bits; and if the second identification is that the difference between the decryption values corresponding to the first N bits of the sub-code and the decryption values corresponding to the last N bits is less than 0, the difference between the decryption values of the first N bits of the encrypted sub-code and the decryption values of the last N bits is equal to the negative value of the encryption values of the last N bits.
In step 580, the decryption device determines the value of each sub-code according to the encrypted value of the first N bits and the decrypted value of the last N bits of each sub-code, and combines the values of the plurality of sub-codes to obtain the code of the source media file.
In the embodiment, compared with a simple stream type encryption algorithm or a multi-key encryption algorithm, the embodiment uses a mathematical formula and a mode of adding new flag bytes, no key participates in the whole encryption process, the risk of decrypting the media file caused by key leakage is prevented, meanwhile, the newly inserted flag bytes break through the sequential organization structure of the original media file, and the media file is guaranteed to be difficult to crack.
Fig. 6 is a schematic structural diagram of some embodiments of a media file encryption apparatus according to the present disclosure. The encryption apparatus includes a source file splitting unit 610, an encrypted value generating unit 620, an identification setting unit 630, and an encrypted file generating unit 640.
The source file splitting unit 610 is configured to split the encoding of the source media file by 2N bits, resulting in a plurality of sub-encodings, where N is a positive integer.
In some embodiments, the source media file is an audio file.
In some embodiments, the value of N is determined based on the format of the source media file. For example, if the audio file is in an 8k 16-bit format, the coding of the audio file may be split according to 2 bytes, i.e., every 16 bits, to obtain a plurality of sub-codes, where N is 8 bits, i.e., 1 byte.
The cryptographic value generating unit 620 is configured to, for each sub-code, take a value corresponding to last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as a first cryptographic value of the sub-code, and take an absolute value of a difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second cryptographic value of the sub-code.
In some embodiments, the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value. It will be appreciated by those skilled in the art that the first cryptographic value may also be a cryptographic value of the last N bits and the second cryptographic value may be a cryptographic value of the first N bits, as long as the encryption apparatus and the decryption apparatus agree.
In some embodiments, when the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is greater than the overflow threshold, the difference between the sum of the values corresponding to the first N bits and the values corresponding to the last N bits and the overflow threshold is subtracted by 1 as the encrypted value of the first N bits of the sub-code.
In some embodiments, the overflow threshold is the maximum value of the binary corresponding to the N bits.
In some embodiments, when the sum of the value corresponding to the first N bits and the value corresponding to the last N bits is less than or equal to the overflow threshold, the sum of the value corresponding to the first N bits and the value corresponding to the last N bits is used as the encrypted value of the first N bits of the sub-code.
In some embodiments, when the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is greater than or equal to 0, the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is taken as the encrypted value of the last N bits of the sub-code.
In some embodiments, when the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is less than 0, the negative value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits is taken as the encrypted value of the last N bits of the sub-code.
The flag setting unit 630 is configured to set a first flag and a second flag at a predetermined position of each sub-code, wherein the first flag is configured to identify whether a sum of values corresponding to the first N bits and values corresponding to the last N bits is greater than an overflow threshold, and the second flag is configured to identify whether a difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0.
In some embodiments, the first and second identifiers are represented by 1/2 × N-bit values, respectively, where N is an even number.
The encrypted file generating unit 640 is configured to determine the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier, and combine the encrypted values of the plurality of sub-codes to obtain the code of the encrypted media file.
In the embodiment, the media file is encrypted by using a mathematical formula and a form of changing the structure of the media file, the encryption is not performed by using a key in the process, the risk that the media file is decrypted when being obtained due to the leakage of the key is prevented, and meanwhile, the sequence organization structure of the original media file is broken by the newly inserted identifier, so that the media file is difficult to crack.
Fig. 7 is a schematic structural diagram of some embodiments of a media file decryption apparatus according to the present disclosure. The decryption apparatus includes an encrypted file splitting unit 710, an identification deletion unit 720, a sub-code decryption unit 730, and a source file generation unit 740.
The encrypted file splitting unit 710 is configured to split the code of the encrypted media file according to every other first identifier and second identifier, so as to obtain a plurality of encrypted sub-codes, where each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether a sum of a decryption value corresponding to a first N bits of each sub-code and a decryption value corresponding to a second N bits of each sub-code is greater than an overflow threshold, and the second identifier is configured to identify whether a difference between the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the N bits of each sub-code after decryption is greater than or equal to 0.
In some embodiments, the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value.
In some embodiments, the first and second identifiers are represented by 1/2 × N-bit values, respectively, where N is an even number.
The identity deletion unit 720 is configured to remove the first identity and the second identity of each encrypted sub-code, resulting in a first cryptographic value and a second cryptographic value of each encrypted sub-code.
The sub-code decryption unit 730 is configured to determine a decrypted value of the first N bits and a decrypted value of the last N bits of each sub-code based on the first identifier and the second identifier, and the first encrypted value and the second encrypted value of each encrypted sub-code, and determine a value of each sub-code based on the decrypted value of the first N bits and the decrypted value of the last N bits of each sub-code.
For example, if the first flag indicates that the sum of the values corresponding to the first N bits of the sub-code and the values corresponding to the last N bits is greater than the overflow threshold, the sum of the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to + 1; and if the first identification is that the sum of the values corresponding to the first N bits and the values corresponding to the last N bits of the sub-code is less than or equal to the overflow threshold, the sum of the decrypted values of the first N bits and the decrypted values of the last N bits of the encrypted sub-code is equal to the encrypted value of the first N bits.
For another example, if the second identifier is that the difference between the values corresponding to the first N bits of the sub-code and the values corresponding to the second N bits is greater than or equal to 0, the difference between the decrypted value of the first N bits of the encrypted sub-code and the decrypted value of the second N bits is equal to the encrypted value of the second N bits; and if the second identifier is that the difference between the values corresponding to the first N bits of the sub-code and the values corresponding to the last N bits is less than 0, the difference between the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits is equal to the negative value of the encrypted values of the last N bits.
In some embodiments, each sub-coded value is a combination of the first N bits of the value and the last N bits of the value.
The source file generating unit 740 is configured to combine the plurality of sub-encoded values resulting in an encoding of the source media file.
In the above embodiment, the decryption device calculates the actual value of each sub-code according to the first identifier and the second identifier, and further obtains the code of the source media file.
Fig. 8 is a schematic structural diagram of some embodiments of the media file encryption and decryption system of the present disclosure. The encryption and decryption system comprises a media file encryption device 810 and a media file decryption device 820, wherein the media file encryption device 810 and the media file decryption device 820 have been described in detail in the above embodiments. The media file encryption device 810 and the media file decryption device 820 may be two servers.
In some embodiments, the encryption and decryption system is applied to an intelligent voice navigation system, and the implementation is simple and efficient through practical detection, and has wider adaptability.
Fig. 9 is a schematic structural diagram of some embodiments of an electronic device of the present disclosure. The electronic device includes a memory 910 and a processor 920. Wherein: the memory 910 may be a magnetic disk, flash memory, or any other non-volatile storage medium. The electronic equipment can be positioned in the media file encryption device and also can be positioned in the media file decryption device. The electronic device is located in the media file encryption apparatus, the memory 910 is configured to store the instructions in the embodiments corresponding to fig. 1, 2, and 5, and when located in the media file decryption apparatus, the memory 910 is configured to store the instructions in the embodiments corresponding to fig. 3, 4, and 5. Coupled to memory 910, processor 920 may be implemented as one or more integrated circuits, such as a microprocessor or microcontroller. The processor 920 is configured to execute instructions stored in a memory.
In some embodiments, processor 920 is coupled to memory 910 through a BUS BUS 930. The electronic device 900 may also be coupled to an external storage system 950 via a storage interface 940 for retrieving external data, and may also be coupled to a network or another computer system (not shown) via a network interface 960. And will not be described in detail herein.
In this embodiment, the security of the media file is improved.
In other embodiments, a computer-readable storage medium has stored thereon computer program instructions which, when executed by a processor, implement the steps of the method in the embodiments corresponding to fig. 1-5. As will be appreciated by one skilled in the art, embodiments of the present disclosure may be provided as a method, apparatus, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Thus far, the present disclosure has been described in detail. Some details that are well known in the art have not been described in order to avoid obscuring the concepts of the present disclosure. It will be fully apparent to those skilled in the art from the foregoing description how to practice the presently disclosed embodiments.
Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the foregoing examples are for purposes of illustration only and are not intended to limit the scope of the present disclosure. It will be appreciated by those skilled in the art that modifications may be made to the above embodiments without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.
Claims (15)
1. A media file encryption method, comprising:
splitting the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer;
for each sub-code, taking the value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as the first encrypted value of the sub-code, and taking the absolute value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as the second encrypted value of the sub-code;
setting a first identifier and a second identifier at a preset position of each sub-code, wherein the first identifier is configured to identify whether the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is greater than an overflow threshold value, and the second identifier is configured to identify whether the difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0;
determining the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier; and
and combining the plurality of sub-coded encrypted values to obtain the code of the encrypted media file.
2. The media file encryption method of claim 1,
the overflow threshold is the maximum value corresponding to the N bits.
3. The media file encryption method according to claim 2, wherein the first cryptographic value is a first N-bit cryptographic value, wherein,
when the sum is larger than the overflow threshold, subtracting 1 from the difference value between the sum of the values corresponding to the first N bits and the values corresponding to the last N bits and the overflow threshold, and taking the difference value as the encryption value of the first N bits of the sub-code; and
and when the sum is less than or equal to the overflow threshold, taking the sum of the values corresponding to the first N bits and the values corresponding to the last N bits as the encryption value of the first N bits of the sub-code.
4. The media file encryption method of claim 1, wherein the second cryptographic value is a cryptographic value of the last N bits, wherein,
when the difference is greater than or equal to 0, taking the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as the encrypted value of the last N bits of the sub-code; and
and when the difference is less than 0, taking the negative value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as the encryption value of the last N bits of the sub-code.
5. The media file encryption method according to any one of claims 1 to 4,
the first mark and the second mark are respectively represented by 1/2 × N bits, where N is an even number.
6. A media file decryption method, comprising:
splitting the code of an encrypted media file according to a first identifier and a second identifier every other to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether the sum of a decryption value corresponding to the first N bits of each sub-code and a decryption value corresponding to the last N bits of each sub-code is greater than an overflow threshold, and the second identifier is configured to identify whether the difference between the decryption value corresponding to the first N bits of each sub-code and the decryption value corresponding to the last N bits of each sub-code is greater than or equal to 0;
removing the first identifier and the second identifier of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code;
determining the decrypted value of the first N bits and the decrypted value of the last N bits of each sub-code according to the first identifier and the second identifier and the first encrypted value and the second encrypted value of each encrypted sub-code;
determining the value of each sub-code according to the decrypted values of the first N bits and the decrypted values of the last N bits of each sub-code; and
and combining the values of the plurality of sub-codes to obtain the code of the source media file.
7. The media file decryption method of claim 6,
the overflow threshold is the maximum value corresponding to the N bits.
8. The media file decryption method of claim 7, wherein the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value, wherein,
if the first identifier indicates that the sum of the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits of the sub-code is greater than the overflow threshold, the sum of the decrypted values of the first N bits of the sub-code and the decrypted values of the last N bits of the sub-code is equal to +1 of the sum of the encrypted values of the first N bits and the overflow threshold; and
if the first identifier indicates that the sum of the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits of the sub-code is less than or equal to the overflow threshold, the sum of the decrypted values of the first N bits of the sub-code and the decrypted values of the last N bits of the sub-code is equal to the encrypted value of the first N bits.
9. The media file decryption method of any of claims 6 to 8, wherein the first cryptographic value is a first N-bit cryptographic value and the second cryptographic value is a second N-bit cryptographic value, wherein,
if the second identifier is that the difference between the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits is greater than or equal to 0, the difference between the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits of the encrypted sub-code is equal to the encrypted value of the last N bits; and
if the second identifier is that the difference between the decrypted values corresponding to the first N bits of the sub-code and the decrypted values corresponding to the last N bits is less than 0, the difference between the decrypted values of the first N bits of the encrypted sub-code and the decrypted values of the last N bits of the encrypted sub-code is equal to the negative value of the encrypted values of the last N bits.
10. A media file transfer method, comprising:
the encryption device splits the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer;
the encryption device takes the value corresponding to the last N bits of the sum of the value corresponding to the first N bits and the value corresponding to the last N bits as the first encryption value of the sub-code, and takes the absolute value of the difference between the value corresponding to the first N bits and the value corresponding to the last N bits as the second encryption value of the sub-code;
the encryption device sets a first identifier and a second identifier at a preset position of each sub-code, wherein the first identifier is configured to identify whether the sum of the values corresponding to the first N bits and the values corresponding to the last N bits is larger than an overflow threshold value, and the second identifier is configured to identify whether the difference between the values corresponding to the first N bits and the values corresponding to the last N bits is larger than or equal to 0;
the encryption device determines the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier, combines the encrypted values of a plurality of sub-codes to obtain the code of the encrypted media file, and sends the code of the encrypted media file to decryption equipment; and
the decryption device splits the code of the encrypted media file according to every other first identifier and every other second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier;
the decryption device removes the first identifier and the second identifier of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code;
the decryption device determines the decrypted value of the first N bits and the decrypted value of the last N bits of each sub-code according to the first identifier and the second identifier and the first encrypted value and the second encrypted value of each encrypted sub-code;
and the decryption device determines the value of each sub-code according to the decryption value of the first N bits and the decryption value of the last N bits of each sub-code, and combines a plurality of sub-code values to obtain the code of the source media file.
11. A media file encryption apparatus comprising:
the source file splitting unit is configured to split the code of the source media file according to 2N bits to obtain a plurality of sub-codes, wherein N is a positive integer;
an encrypted value generating unit configured to, for each of the sub-codes, take a value corresponding to last N bits of a sum of a value corresponding to the first N bits and a value corresponding to the last N bits as a first encrypted value of the sub-code, and take an absolute value of a difference between the value corresponding to the first N bits and the value corresponding to the last N bits as a second encrypted value of the sub-code;
an identifier setting unit configured to set a first identifier and a second identifier at a predetermined position of each of the sub-codes, wherein the first identifier is configured to identify whether a sum of values corresponding to the first N bits and values corresponding to the last N bits is greater than an overflow threshold, and the second identifier is configured to identify whether a difference between the values corresponding to the first N bits and the values corresponding to the last N bits is greater than or equal to 0; and
and the encrypted file generating unit is configured to determine the encrypted value of each sub-code according to the first encrypted value and the second encrypted value of each sub-code and the first identifier and the second identifier, and combine a plurality of encrypted values of the sub-codes to obtain the code of the encrypted media file.
12. A media file decryption apparatus comprising:
the encrypted file splitting unit is configured to split the code of the encrypted media file according to every other first identifier and every other second identifier to obtain a plurality of encrypted sub-codes, wherein each encrypted sub-code corresponds to 2N bits except the first identifier and the second identifier, N is a positive integer, the first identifier is configured to identify whether the sum of the decryption value corresponding to the first N bits and the decryption value corresponding to the last N bits of each sub-code is greater than an overflow threshold value, and the second identifier is configured to identify whether the difference between the decryption value corresponding to the first N bits and the decryption value corresponding to the decrypted N bits of each sub-code is greater than or equal to 0;
the identification deleting unit is configured to remove the first identification and the second identification of each encrypted sub-code to obtain a first encrypted value and a second encrypted value of each encrypted sub-code;
a sub-code decryption unit configured to determine a decrypted value of the first N bits and a decrypted value of the last N bits of each sub-code according to the first identifier and the second identifier and the first encrypted value and the second encrypted value of each encrypted sub-code, and determine a value of each sub-code according to the decrypted value of the first N bits and the decrypted value of the last N bits of each sub-code; and
and the source file generating unit is configured to combine the sub-coded values to obtain the coding of the source media file.
13. A media file encryption and decryption system comprising:
the media file encryption apparatus of claim 11; and
the media file decryption device of claim 12.
14. An electronic device, comprising:
a memory; and
a processor coupled to the memory, the processor configured to perform the media file encryption method of any of claims 1 to 5, or the media file decryption method of any of claims 6 to 9, or the media file transmission method of claim 10, based on instructions stored in the memory.
15. A non-transitory computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the media file encryption method of any one of claims 1 to 5, or the media file decryption method of any one of claims 6 to 9, or the media file transmission method of claim 10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010808494.1A CN114143014B (en) | 2020-08-12 | 2020-08-12 | Media file encryption method, decryption method, transmission method, device and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010808494.1A CN114143014B (en) | 2020-08-12 | 2020-08-12 | Media file encryption method, decryption method, transmission method, device and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114143014A true CN114143014A (en) | 2022-03-04 |
CN114143014B CN114143014B (en) | 2024-05-14 |
Family
ID=80438022
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010808494.1A Active CN114143014B (en) | 2020-08-12 | 2020-08-12 | Media file encryption method, decryption method, transmission method, device and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114143014B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050036618A1 (en) * | 2002-01-16 | 2005-02-17 | Infineon Technologies Ag | Calculating unit and method for performing an arithmetic operation with encrypted operands |
JP2008107656A (en) * | 2006-10-26 | 2008-05-08 | Canon Inc | Encrypting apparatus and authentication apparatus |
CN103684761A (en) * | 2013-12-25 | 2014-03-26 | 广西宝恒电子科技有限公司 | Coding and decoding method |
CN103853985A (en) * | 2012-12-05 | 2014-06-11 | 中国移动通信集团黑龙江有限公司 | Data encryption method, decryption method and decryption device |
-
2020
- 2020-08-12 CN CN202010808494.1A patent/CN114143014B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050036618A1 (en) * | 2002-01-16 | 2005-02-17 | Infineon Technologies Ag | Calculating unit and method for performing an arithmetic operation with encrypted operands |
JP2008107656A (en) * | 2006-10-26 | 2008-05-08 | Canon Inc | Encrypting apparatus and authentication apparatus |
CN103853985A (en) * | 2012-12-05 | 2014-06-11 | 中国移动通信集团黑龙江有限公司 | Data encryption method, decryption method and decryption device |
CN103684761A (en) * | 2013-12-25 | 2014-03-26 | 广西宝恒电子科技有限公司 | Coding and decoding method |
Also Published As
Publication number | Publication date |
---|---|
CN114143014B (en) | 2024-05-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11184164B2 (en) | Secure crypto system attributes | |
CN110391900B (en) | Private key processing method based on SM2 algorithm, terminal and key center | |
CN106878013B (en) | File encryption and decryption method and device | |
US20140317407A1 (en) | Incremental mac tag generation device, method, and program, and message authentication device | |
CN113098675B (en) | Binary data encryption system and method based on polynomial complete homomorphism | |
CN112464258B (en) | Data encryption and decryption methods, devices, equipment and storage medium | |
CN111404892B (en) | Data supervision method and device and server | |
CN114826590B (en) | Packet mode encryption method, packet mode decryption method, packet mode encryption device, packet mode decryption device and packet mode decryption equipment | |
CN114285562A (en) | Data encryption method and device | |
CN112287366A (en) | Data encryption method and device, computer equipment and storage medium | |
CN113326518B (en) | Data processing method and device | |
CN108199836B (en) | Method and device for binding and unbinding key and equipment | |
US20240178999A1 (en) | Method for data encryption, terminal device and non-transitory computer-readable storage medium | |
CN109951275B (en) | Key generation method and device, computer equipment and storage medium | |
CN114143014B (en) | Media file encryption method, decryption method, transmission method, device and system | |
EP4084484B1 (en) | Method and device for encryption of video stream, communication equipment, and storage medium | |
CN114745114A (en) | Key agreement method, device, equipment and medium based on password derivation | |
CN114329555A (en) | Video file encryption processing method and device, storage medium and equipment | |
CN115935299A (en) | Authorization control method, device, computer equipment and storage medium | |
CN115695278A (en) | Message forwarding method, controller and message forwarding system | |
CN113326530A (en) | Key negotiation method suitable for sharing keys of two communication parties | |
CN111131158A (en) | Single byte symmetric encryption and decryption method, device and readable medium | |
CN117221878B (en) | Information security control method and device based on wireless network equipment | |
CN114124413A (en) | Media file encryption method, decryption method, transmission method and device | |
CN117040913B (en) | Cloud resource sharing data security transmission method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |