File encryption and decryption private tool establishment method

Through the file encryption and decryption private tool using AES and RSA encryption algorithms, the problems of insufficient encryption strength, inconvenient key management and high cost in existing tools are solved, and efficient encryption and decryption of files in various formats are achieved.

CN119544218APending Publication Date: 2025-02-28BEIYIN FINANCIAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411605062.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

Existing file encryption and decryption tools have problems such as insufficient encryption strength, inconvenient key management, inefficient decryption efficiency, fewer file formats and high cost.

Method used

It provides a private tool for file encryption and decryption, adopts AES and RSA encryption algorithms, supports password-free decryption, and simplifies password management by storing passwords and file formats with file byte streams, and ensures file integrity through MD5 signatures.

Benefits of technology

It realizes efficient encryption and decryption of files in various formats, simplifies password management, reduces costs, and ensures file integrity through MD5 signatures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544218A_ABST
    Figure CN119544218A_ABST
Patent Text Reader

Abstract

The invention discloses a method for establishing a file encryption and decryption private tool, and the method comprises the steps: carrying out the encryption processing of a user file, and obtaining an encrypted file; and decryption processing is carried out on the encrypted file, the decryption processing comprises password decryption and password-free decryption, the user carries out file decryption by using the password recorded by himself / herself, and meanwhile, a password-free decryption function is supported and configured. According to the method for encrypting byte streams of files in various formats, a file to be encrypted is firstly generated into a corresponding file byte stream, when the encryption algorithm is used for encrypting and decrypting the stream, the encrypted file byte stream is analyzed to confirm the decrypted file format, then the byte stream is decrypted, and finally a corresponding non-encrypted file is generated. The tool can encrypt and decrypt files in various formats.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of file encryption and decryption, and in particular to a method for establishing a private tool for file encryption and decryption. Background Art

[0002] With the rapid development and widespread application of information technology, the processing, storage and transmission of file data have become increasingly frequent and important. However, this process is also accompanied by serious security risks, such as data leakage, illegal access and tampering. These threats may not only lead to the leakage of personal privacy, but also have a serious impact on corporate trade secrets and national security. Traditional file encryption methods have problems such as insufficient encryption strength, inconvenient key management, and low decryption efficiency, which are difficult to meet the high requirements of modern users for file security protection. Therefore, it is particularly important to develop an efficient, secure and easy-to-use file encryption and decryption tool.

[0003] The technical solutions of file encryption and decryption tools mainly include the selection of encryption technology, key management, user interface design, performance optimization and file type support. Most of the file encryption and decryption tools on the market now support the encryption of several similar file formats, and require users to record the file encryption passwords themselves and enter the corresponding passwords when decrypting. The password memory management is complicated. At the same time, most advanced encryption tools or software use paid encryption strategies, which are costly for individual and corporate users.

[0004] Disadvantages of existing technology:

[0005] 1. Support fewer encrypted file formats: Most encryption and decryption tools on the market only support encryption and decryption of one or several file formats;

[0006] 2. It is troublesome for users to remember passwords and they are easy to forget: Password management is an important part of encryption technology, but the process of password generation, storage, and management is complex and prone to errors;

[0007] 3. Encrypted files are easily cracked: Due to the choice of encryption algorithm, loopholes in different encryption algorithms and leakage of secret keys will cause the risk of encrypted files being cracked;

[0008] 4. Some advanced encryption and decryption tools or software on the market require high purchase and maintenance costs, which is costly for enterprises and individual users. Summary of the invention

[0009] In view of the above problems, the present invention is proposed to provide a method for establishing a private tool for file encryption and decryption that overcomes the above problems or at least partially solves the above problems.

[0010] According to one aspect of the present invention, a method for establishing a private file encryption and decryption tool is provided, the method comprising:

[0011] Encrypt user files to obtain encrypted files;

[0012] Decrypt encrypted files, including decryption with password and decryption without password. Users can use their own recorded passwords to decrypt files, and the decryption without password function can also be configured.

[0013] Optionally, the encrypting the user file specifically includes:

[0014] The user selects the file to be encrypted through the encryption function window, enters the encryption password, and then submits;

[0015] The backend receives the user's encrypted file and password, and converts the received file to be encrypted into a byte stream array;

[0016] Convert the password into binary data and use the MD5 encryption algorithm to obtain the digest password;

[0017] AES key expansion;

[0018] AES encryption algorithm encryption: first convert the file byte stream into binary data, and then divide it into several 128-bit independent groups. If the length of the file binary data is not an integer multiple of 128 bits, it needs to be padded with 0, and then 11 rounds of encryption are performed. Each group needs to be encrypted. First, byte substitution is performed to replace each byte of the group, and then the bytes of each row are circularly shifted to the left, and then the bytes of each column are mixed through matrix multiplication. Finally, the data of each group is XORed with the round key to complete the round encryption. After 11 rounds of encryption, the file stream is encrypted into a ciphertext binary array, and finally the ciphertext binary stream is converted into a byte stream;

[0019] Then the ciphertext binary stream is encrypted with MD5 to generate a 32-bit summary signature;

[0020] At the same time, the RSA asymmetric encryption algorithm: take (e, n) from the public key, convert the plaintext password into a character array, then loop through the character array to encrypt each character, convert the character into a number m through the ASC code table, then take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the corresponding ciphertext password;

[0021] At the same time, the RSA asymmetric encryption algorithm is used to encrypt the file format with the public key to generate the ciphertext of the file format;

[0022] Take (e,n) from the public key, convert the file format into a character array, loop through the character array to encrypt each character, convert the character into a number m through the ASC code table, take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the ciphertext of the corresponding file format;

[0023] Then concatenate the 12-bit ciphertext password, the 32-bit signature summary, the 8-bit file format ciphertext, and the ciphertext byte stream of the file together;

[0024] Finally, the entire byte stream is generated into an encrypted file .enc.

[0025] Optionally, converting the password into binary data and using the MD5 encryption algorithm to obtain a digest password specifically includes:

[0026] First, fill the password with data (add 0 and 1 at the end) so that its length modulo 512 is 448;

[0027] A 64-bit data length field is appended to the end of the padded data, and then four 32-bit variables are defined. At the same time, the padded items are divided into several 512-bit groups, and each block is divided into 16 32-bit sub-groups. Then, each sub-group is used cyclically to perform F function bit operations on the four 32-bit variables until all group processing is completed. Finally, the four 32-bit binary results are concatenated into a 128 binary digest, and finally the binary digest is converted into hexadecimal to generate a 32-bit digest password.

[0028] Optionally, the AES key expansion specifically includes: first converting the summary password into a 128-bit binary key, then initializing the key to a 4*4 matrix with 4 bytes in each column, and then expanding the matrix to generate a 44-column extended key array, and the new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and the cyclic expansion finally generates 44 columns of extended key data.

[0029] Optionally, the step of encrypting the ciphertext binary stream by MD5 to generate a 32-bit summary signature specifically includes:

[0030] First, pad the ciphertext binary stream with data so that its length modulo 512 is 448. Then, append a 64-bit data length field to the end of the padded data. Then define four 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on the four 32-bit variables in a loop until all group processing is completed. Finally, concatenate the four 32-bit binary results into a 128 binary summary. Finally, convert the binary summary into hexadecimal to generate a 32-bit summary signature.

[0031] Optionally, the password-protected decryption in the decryption process of the encrypted file includes:

[0032] The user selects password decryption through the decryption function window, selects the file to be decrypted, enters the encryption password, and then submits;

[0033] After receiving the user's encrypted file and password, first convert the received encrypted file into a byte stream array;

[0034] Then take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character;

[0035] RSA algorithm decryption, concatenating the plaintext characters to generate the corresponding plaintext password;

[0036] Compare the decrypted plain text password with the password entered by the user. If they are inconsistent, a password error is reported and the decryption fails.

[0037] Parse the byte stream to extract the signature of bits 13-44 and the ciphertext byte stream after bit 52;

[0038] MD5 encryption to obtain the summary signature;

[0039] Verify the digest signature generated in the previous step with the signature of 13-44 bits to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted;

[0040] According to the plain text password entered by the user, use the MD5 encryption algorithm to obtain the digest password;

[0041] At the same time, extract the file format ciphertext from bits 45-52 in the byte stream, remove the trailing null character, and then use the RSA algorithm to decrypt:

[0042] AES key expansion;

[0043] Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the obtained 44 columns of secret key data, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to decrypt each byte of the group by byte substitution. After 11 rounds of decryption, the plaintext binary data is obtained, and finally the plaintext binary array is converted into the byte stream of the source file.

[0044] Finally, the generated byte stream is converted into a file of the corresponding file format after decryption.

[0045] Optionally, the AES key expansion specifically includes: first converting the obtained summary password into a 128-bit binary key, then initializing the key to a 4*4 matrix with 4 bytes in each column, and then expanding the matrix to generate a 44-column extended key array, and the new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and the cyclic expansion finally generates 44 columns of extended key data.

[0046] Optionally, the RSA algorithm decryption and concatenation of plain text characters to generate a corresponding plain text password specifically includes:

[0047] Take out (d,n) from the private key, convert the file format ciphertext into a character array, then loop through the character array to decrypt each character, convert the character into a number c through the ASC table, then take the d times logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext password.

[0048] Optionally, the password-free decryption in the decryption process of the encrypted file includes:

[0049] The user selects decryption without password in the decryption function window, selects the file to be decrypted, and then submits the encrypted file received from the user to the backend, which first converts the received encrypted file into a byte stream array form;

[0050] Parse the byte stream to extract the signature of bits 13-44 and the ciphertext byte stream after bit 52;

[0051] MD5 algorithm obtains summary signature: converts the ciphertext byte stream into binary to generate a binary array, and then encrypts the ciphertext binary array with MD5: first fill the ciphertext binary stream with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables, and divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups, then use each sub-group to perform F function bit operation on 4 32-bit variables in a loop, until all group processing is completed, and finally splice the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary signature;

[0052] Verify the obtained summary signature with the signature in the byte stream to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted.

[0053] Then take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character;

[0054] Decrypt the password using the RSA algorithm: extract (d, n) from the private key, convert the ciphertext password into a character array, then loop through the character array to decrypt each character, convert the character into a number c using the ASC table, then take the logarithm of the number c d times and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding plaintext password;

[0055] Perform MD5 encryption on the password to obtain a digest password: first pad the password with data so that its length modulo 512 is 448, then append a 64-bit data length field to the end of the padded data, and then define four 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on the four 32-bit variables in a loop until all group processing is completed. Finally, concatenate the four 32-bit binary results into a 128 binary digest, and finally convert the binary digest into hexadecimal to generate a 32-bit digest password;

[0056] At the same time, extract the file format ciphertext from bits 45-52 in the byte stream, remove the trailing null character, and then use the RSA encryption algorithm to decrypt: extract (d,n) from the private key, and convert the file format ciphertext to a character array, then loop through the character array to decrypt each character, convert the character to a number c through the ASC table, then take the d-time logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number to a character using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext;

[0057] AES key expansion;

[0058] Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the 44 columns of secret key data obtained in step 11, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to perform byte substitution decryption on each byte of the group. After 11 rounds of decryption, the plaintext binary data is obtained, and finally the plaintext binary array is converted into the byte stream of the source file.

[0059] Finally, the generated byte stream is converted into a decrypted file.

[0060] Optionally, the AES key extension specifically includes:

[0061] First, convert the obtained summary password into a 128-bit binary key, then initialize the key to a 4*4 matrix with 4 bytes per column, and then expand the matrix to generate a 44-column extended key array. The rules of the new key matrix are as follows: If the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is replaced by byte, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and cyclic expansion is finally generated to generate 44 columns of extended key data.

[0062] The present invention provides a method for establishing a private tool for file encryption and decryption, the method comprising: encrypting user files to obtain encrypted files; decrypting encrypted files, including: decryption with password and decryption without password, the user uses the password recorded by himself to decrypt the file, and supports the configuration of decryption without password. The method of encrypting the byte stream of files of various formats first generates a corresponding file byte stream from the file to be encrypted, encrypts the stream using an encryption algorithm, and during decryption, confirms the file format after decryption by parsing the encrypted file byte stream, and then decrypts the byte stream, finally generates a corresponding non-encrypted file, and realizes the encryption and decryption of files of various formats by this tool.

[0063] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0065] Figure 1 A flowchart of encrypting user files provided by an embodiment of the present invention;

[0066] Figure 2 A flowchart of password decryption provided for an embodiment of the present invention;

[0067] Figure 3 A flowchart of password-free decryption provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0068] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0069] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.

[0070] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0071] A method for establishing a private tool for file encryption and decryption includes: a user file encryption function and an encrypted file decryption function.

[0072] First, the encryption function. The user opens the tool, clicks the encryption button, and the encryption function window opens. The user can select the file selection box for the encrypted file, enter the encryption password, and submit to confirm the encryption;

[0073] like Figure 1 As shown, the encryption process includes:

[0074] 1. The user selects the file to be encrypted through the encryption function window, enters the encryption password, and then submits;

[0075] 2. The background receives the user's encrypted file and password, and first converts the received file to be encrypted into a byte stream array;

[0076] 3. Convert the password into binary data and use the MD5 encryption algorithm to obtain the digest password: first fill the password with data (add 0 and 1 at the end) to make its length 448 modulo 512, then add a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on 4 32-bit variables in a loop until all group processing is completed. Finally, splice the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary password;

[0077] 4. AES key expansion: first convert the digest password into a 128-bit binary key, then initialize the key to a 4*4 matrix with 4 bytes per column, then expand the matrix to generate a 44-column extended key array. The new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: first, the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate the i-column word. In this way, the cyclic expansion finally generates 44 columns of extended key data;

[0078] 5. AES encryption algorithm encryption: first convert the file byte stream into binary data, and then divide it into several 128-bit independent groups. If the length of the file binary data is not an integer multiple of 128 bits, it needs to be padded with 0, and then 11 rounds of encryption are performed. Each group needs to be encrypted. First, byte substitution is performed to replace each byte of the group, and then the bytes of each row are circularly shifted to the left, and then the bytes of each column are mixed through matrix multiplication. Finally, the data of each group is XORed with the round key to complete the round encryption. After 11 rounds of encryption, the file stream is encrypted into a ciphertext binary array, and finally the ciphertext binary stream is converted into a byte stream;

[0079] 6. Then perform MD5 encryption on the ciphertext binary stream to generate a 32-bit summary signature: first fill the ciphertext binary stream with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on 4 32-bit variables in a loop until all group processing is completed. Finally, concatenate the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary signature;

[0080] 7. RSA asymmetric encryption algorithm: extract (e, n) from the public key, convert the plaintext password into a character array, traverse the character array and encrypt each character, convert the character into a number m through the ASC code table, then take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the corresponding ciphertext password;

[0081] 8. At the same time, use the RSA asymmetric encryption algorithm to encrypt the file format with the public key to generate the ciphertext of the file format;

[0082] Take (e,n) from the public key, convert the file format into a character array, loop through the character array to encrypt each character, convert the character into a number m through the ASC code table, take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the ciphertext of the corresponding file format;

[0083] 9. Then concatenate the 12-bit ciphertext password (fill in blanks if insufficient), the 32-bit signature summary, the 8-bit file format ciphertext (fill in blanks if insufficient), and the ciphertext byte stream of the file together;

[0084] 10. Finally, the entire byte stream is generated into an encrypted file .enc.

[0085] The decryption of encrypted files can be divided into two forms: decryption with password and decryption without password. Users can use their own recorded passwords to decrypt files, and the decryption without password function can also be configured.

[0086] like Figure 2 As shown, there are password decryption methods, including:

[0087] 1. The user selects password decryption through the decryption function window, selects the file to be decrypted, enters the encrypted password, and then submits;

[0088] 2. After receiving the user's encrypted file and password, convert the received encrypted file into a byte stream array;

[0089] 3. Take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character;

[0090] 4. RSA algorithm decryption: Take (d, n) from the private key, convert the ciphertext password into a character array, then loop through the character array to decrypt each character, convert the character into a number c through the ASC table, then take the logarithm operation result of the number c d times and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding plaintext password;

[0091] 5. Compare the decrypted plain text password with the password entered by the user. If they are inconsistent, a password error is reported and the decryption fails.

[0092] 6. Parse the byte stream to extract the signature of 13-44 bits and the ciphertext byte stream after 52 bits;

[0093] 7. MD5 encryption to obtain summary signature: convert the ciphertext byte stream into binary to generate a binary array, and then encrypt the ciphertext binary array with MD5: first fill the ciphertext binary stream with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables, and divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups, then use each sub-group to perform F function bit operation on 4 32-bit variables in a loop, until all group processing is completed, and finally splice the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary signature;

[0094] 8. Verify the digest signature generated in the previous step with the signature of 13-44 bits to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted;

[0095] 9. According to the plain text password entered by the user, use the MD5 encryption algorithm to obtain the digest password: first fill the password with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on 4 32-bit variables in a loop until all group processing is completed. Finally, splice the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary password;

[0096] 10. At the same time, extract the file format ciphertext from bits 45-52 of the byte stream, remove the trailing null character, and then use the RSA algorithm to decrypt: extract (d, n) from the private key, and convert the file format ciphertext to a character array, then loop through the character array to decrypt each character, convert the character to a number c through the ASC table, then take the d-time logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number to a character using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext;

[0097] 11. AES key expansion: first convert the summary password obtained in step 9 into a 128-bit binary key, then initialize the key to a 4*4 matrix with 4 bytes per column, then expand the matrix to generate a 44-column extended key array. The new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: first, the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate the i-column word. In this way, the cyclic expansion finally generates 44 columns of extended key data;

[0098] 12. Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the 44 columns of secret key data obtained in step 11, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to perform byte substitution decryption on each byte of the group. After 11 rounds of decryption, the plaintext binary data is obtained. Finally, the plaintext binary array is converted into the byte stream of the source file.

[0099] 13. Finally, convert the generated byte stream into a file of the corresponding file format after decryption.

[0100] like Figure 3 As shown, the password-free decryption process includes:

[0101] 1. The user selects decryption without password in the decryption function window, selects the file to be decrypted, and then submits

[0102] 2. The background receives the encrypted file from the user and converts it into a byte stream array;

[0103] 3. Parse the byte stream to extract the signature of 13-44 bits and the ciphertext byte stream after 52 bits;

[0104] 4. Obtain summary signature using MD5 algorithm: convert the ciphertext byte stream into binary format to generate a binary array, and then perform MD5 encryption on the ciphertext binary array: first fill the ciphertext binary stream with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on 4 32-bit variables in a loop until all group processing is completed. Finally, concatenate the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary signature.

[0105] 5. Verify the digest signature obtained in step 4 with the signature in the byte stream to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted;

[0106] 6. Take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character;

[0107] 7. Decrypt the password using the RSA algorithm: extract (d, n) from the private key, convert the ciphertext password into a character array, then loop through the character array to decrypt each character, convert the character into a number c using the ASC table, then take the logarithm of the number c d times and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding plaintext password;

[0108] 8. Perform MD5 encryption on the password to obtain a digest password: first fill the password with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define four 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on the four 32-bit variables in a loop until all group processing is completed. Finally, concatenate the four 32-bit binary results into a 128 binary digest, and finally convert the binary digest into hexadecimal to generate a 32-bit digest password.

[0109] 9. At the same time, extract the file format ciphertext from bits 45-52 in the byte stream, remove the trailing null character, and then use the RSA encryption algorithm to decrypt: extract (d, n) from the private key, and convert the file format ciphertext to a character array, then loop through the character array to decrypt each character, convert the character to a number c through the ASC table, then take the d-time logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number to a character using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext;

[0110] 10. AES key expansion: first convert the summary password obtained in step 8 into a 128-bit binary key, then initialize the key to a 4*4 matrix with 4 bytes per column, then expand the matrix to generate a 44-column extended key array. The new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: first, the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate the i-column word. In this way, the cyclic expansion finally generates 44 columns of extended key data;

[0111] 11. Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the 44 columns of secret key data obtained in step 11, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to perform byte substitution decryption on each byte of the group. After 11 rounds of decryption, the plaintext binary data is obtained. Finally, the plaintext binary array is converted into the byte stream of the source file.

[0112] 12. Finally, convert the generated byte stream into a decrypted file.

[0113] The tool of the present invention encrypts the byte streams of files of various formats, first generates the corresponding file byte stream from the file to be encrypted, encrypts the stream using an encryption algorithm, and during decryption, confirms the file format after decryption by parsing the encrypted file byte stream, and then decrypts the byte stream, and finally generates the corresponding non-encrypted file, thereby realizing encryption and decryption of files of various formats by the tool;

[0114] First, when performing encryption operations, this tool will splice the user's password ciphertext with the encrypted file byte stream, and then generate an encrypted file from the byte stream data. When decrypting the file, the tool parses the encrypted file into a byte stream, extracts the encrypted password from it, and uses the password to decrypt it to the source file. In this way, users do not need to remember the file password and can directly decrypt the file, while retaining the password-based decryption process;

[0115] When encrypting files, this tool first uses the RSA asymmetric encryption algorithm to encrypt the password, and then uses the AES symmetric encryption algorithm to encrypt the byte stream of the file using the password ciphertext. At the same time, the encrypted stream is encrypted with MD5 to generate a signature to ensure that the file is not tampered with during the file transmission process, thus ensuring the security of the encrypted file;

[0116] At the same time, the encryption algorithms used by this tool include AES symmetric encryption algorithm, RSA asymmetric encryption algorithm, and MD5, which are all open source algorithms. They are easy to use, have no additional fees, and save costs.

[0117] Beneficial effect: The ciphertext information of the password is saved together with the encrypted information of the file in the encrypted file, which saves the work of recording and managing passwords and allows users to focus more on their core demands;

[0118] For files of various formats, encryption and decryption operations are performed in the form of byte streams, and the file format is stored in the encrypted file through ciphertext, so that encryption and decryption of files of most formats can be supported;

[0119] When encrypting, the summary information of the encrypted file content is generated together with the result file. In this way, when decrypting, the summary can be verified to determine whether the file has been modified during the transmission process, thereby ensuring the correctness of the file content.

[0120] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for establishing a private tool for file encryption and decryption, characterized in that: The tool establishment method comprises: Encrypt user files to obtain encrypted files; Decrypt encrypted files, including decryption with password and decryption without password. Users can use their own recorded passwords to decrypt files, and the decryption without password function can also be configured.

2. A method for establishing a private file encryption and decryption tool according to claim 1, characterized in that: The encryption process of the user file specifically includes: The user selects the file to be encrypted through the encryption function window, enters the encryption password, and then submits; The backend receives the user's encrypted file and password, and converts the received file to be encrypted into a byte stream array; Convert the password into binary data and use the MD5 encryption algorithm to obtain the digest password; AES key expansion; AES encryption algorithm encryption: first convert the file byte stream into binary data, and then divide it into several 128-bit independent groups. If the length of the file binary data is not an integer multiple of 128 bits, it needs to be padded with 0, and then 11 rounds of encryption are performed. Each group needs to be encrypted. First, byte substitution is performed to replace each byte of the group, and then the bytes of each row are circularly shifted to the left, and then the bytes of each column are mixed through matrix multiplication. Finally, the data of each group is XORed with the round key to complete the round encryption. After 11 rounds of encryption, the file stream is encrypted into a ciphertext binary array, and finally the ciphertext binary stream is converted into a byte stream; Then the ciphertext binary stream is encrypted with MD5 to generate a 32-bit summary signature; At the same time, the RSA asymmetric encryption algorithm: take (e, n) from the public key, convert the plaintext password into a character array, then loop through the character array to encrypt each character, convert the character into a number m through the ASC code table, then take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the corresponding ciphertext password; At the same time, the RSA asymmetric encryption algorithm is used to encrypt the file format with the public key to generate the ciphertext of the file format; Take (e,n) from the public key, convert the file format into a character array, loop through the character array to encrypt each character, convert the character into a number m through the ASC code table, take the result of the exponential operation of the number m e times and perform a modulus operation on n to generate a ciphertext number, then convert the ciphertext number into characters through the ASC code table, and finally concatenate the ciphertext characters to generate the ciphertext of the corresponding file format; Then concatenate the 12-bit ciphertext password, the 32-bit signature summary, the 8-bit file format ciphertext, and the ciphertext byte stream of the file together; Finally, the entire byte stream is generated into an encrypted file .enc.

3. A method for establishing a private file encryption and decryption tool according to claim 2, characterized in that: The step of converting the password into binary data and obtaining the digest password using the MD5 encryption algorithm specifically includes: First, fill the password with data (add 0 and 1 at the end) so that its length modulo 512 is 448; A 64-bit data length field is appended to the end of the padded data, and then four 32-bit variables are defined. At the same time, the padded items are divided into several 512-bit groups, and each block is divided into 16 32-bit sub-groups. Then, each sub-group is used cyclically to perform F function bit operations on the four 32-bit variables until all group processing is completed. Finally, the four 32-bit binary results are concatenated into a 128 binary digest, and finally the binary digest is converted into hexadecimal to generate a 32-bit digest password.

4. A method for establishing a private file encryption and decryption tool according to claim 2, characterized in that: The AES key expansion specifically includes: first converting the summary password into a 128-bit binary key, then initializing the key to a 4*4 matrix with 4 bytes in each column, and then expanding the matrix to generate a 44-column extended key array. The new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and the cyclic expansion finally generates 44 columns of extended key data.

5. A method for establishing a private file encryption and decryption tool according to claim 2, characterized in that: The step of then performing MD5 encryption on the ciphertext binary stream to generate a 32-bit summary signature specifically includes: First, pad the ciphertext binary stream with data so that its length modulo 512 is 448. Then, append a 64-bit data length field to the end of the padded data. Then define four 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on the four 32-bit variables in a loop until all group processing is completed. Finally, concatenate the four 32-bit binary results into a 128 binary summary. Finally, convert the binary summary into hexadecimal to generate a 32-bit summary signature.

6. A method for establishing a private file encryption and decryption tool according to claim 1, characterized in that: The password-protected decryption in the decryption process of the encrypted file includes: The user selects password decryption through the decryption function window, selects the file to be decrypted, enters the encryption password, and then submits; After receiving the user's encrypted file and password, first convert the received encrypted file into a byte stream array; Then take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character; RSA algorithm decryption, concatenating the plaintext characters to generate the corresponding plaintext password; Compare the decrypted plain text password with the password entered by the user. If they are inconsistent, a password error is reported and the decryption fails. Parse the byte stream to extract the signature of bits 13-44 and the ciphertext byte stream after bit 52; MD5 encryption to obtain the summary signature; Verify the digest signature generated in the previous step with the signature of 13-44 bits to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted; According to the plain text password entered by the user, use the MD5 encryption algorithm to obtain the digest password; At the same time, extract the file format ciphertext from bits 45-52 in the byte stream, remove the trailing null character, and then use the RSA algorithm to decrypt: AES key expansion; Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the obtained 44 columns of secret key data, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to decrypt each byte of the group by byte substitution. After 11 rounds of decryption, the plaintext binary data is obtained, and finally the plaintext binary array is converted into the byte stream of the source file. Finally, the generated byte stream is converted into a file of the corresponding file format after decryption.

7. A method for establishing a private file encryption and decryption tool according to claim 6, characterized in that: The AES key expansion specifically includes: first converting the obtained summary password into a 128-bit binary key, then initializing the key to a 4*4 matrix with 4 bytes in each column, and then expanding the matrix to generate a 44-column extended key array, and the new key matrix rule is as follows: if the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns, if the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is byte replaced, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and the cyclic expansion finally generates 44 columns of extended key data.

8. A method for establishing a private file encryption and decryption tool according to claim 6, characterized in that: The RSA algorithm decryption and concatenation of plain text characters to generate the corresponding plain text password specifically include: Take out (d,n) from the private key, convert the file format ciphertext into a character array, then loop through the character array to decrypt each character, convert the character into a number c through the ASC table, then take the d times logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext password.

9. A method for establishing a private file encryption and decryption tool according to claim 1, characterized in that: The password-free decryption in the decryption process of the encrypted file includes: The user selects decryption without password in the decryption function window, selects the file to be decrypted, and then submits the encrypted file received from the user to the backend, which first converts the received encrypted file into a byte stream array form; Parse the byte stream to extract the signature of bits 13-44 and the ciphertext byte stream after bit 52; MD5 algorithm obtains summary signature: converts the ciphertext byte stream into binary to generate a binary array, and then encrypts the ciphertext binary array with MD5: first fill the ciphertext binary stream with data (add 0 and 1 at the end) to make its length modulo 512 448, then append a 64-bit data length field to the end of the padded data, and then define 4 32-bit variables, and divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups, then use each sub-group to perform F function bit operation on 4 32-bit variables in a loop, until all group processing is completed, and finally splice the 4 32-bit binary results into a 128 binary summary, and finally convert the binary summary into hexadecimal to generate a 32-bit summary signature; Verify the obtained summary signature with the signature in the byte stream to see if they are consistent. If they are inconsistent, it means that the encrypted file has been tampered with and cannot be decrypted. Then take the encrypted ciphertext from the first 12 bits of the byte stream and remove the trailing null character; Decrypt the password using the RSA algorithm: extract (d, n) from the private key, convert the ciphertext password into a character array, then loop through the character array to decrypt each character, convert the character into a number c using the ASC table, then take the logarithm of the number c d times and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number into characters using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding plaintext password; Perform MD5 encryption on the password to obtain a digest password: first pad the password with data so that its length modulo 512 is 448, then append a 64-bit data length field to the end of the padded data, and then define four 32-bit variables. At the same time, divide the padded items into several 512-bit groups, and divide each block into 16 32-bit sub-groups. Then, use each sub-group to perform F function bit operation on the four 32-bit variables in a loop until all group processing is completed. Finally, concatenate the four 32-bit binary results into a 128 binary digest, and finally convert the binary digest into hexadecimal to generate a 32-bit digest password; At the same time, extract the file format ciphertext from bits 45-52 in the byte stream, remove the trailing null character, and then use the RSA encryption algorithm to decrypt: extract (d,n) from the private key, and convert the file format ciphertext to a character array, then loop through the character array to decrypt each character, convert the character to a number c through the ASC table, then take the d-time logarithm operation result of the number c and perform a modulus operation on n to generate a plaintext number, then convert the plaintext number to a character using the ASC code table, and finally concatenate the plaintext characters to generate the corresponding file format plaintext; AES key expansion; Use the AES algorithm to decrypt. First, convert the file byte stream into a binary array, and then divide it into several 128-bit independent groups. Then, according to the 44 columns of secret key data obtained in step 11, traverse 11 4*4 matrices in reverse order and perform 11 rounds of decryption process. All binary 128-bit groups need to be decrypted. First, use the current round secret key and the group data to perform an XOR operation to obtain the intermediate result. Next, perform an inverse operation on the intermediate data matrix to obtain the inverse matrix, and then obtain the inverse operation result of column mixing through inverse matrix multiplication. Then, each row of the result is cyclically right-shifted to obtain the intermediate matrix of the row shift inverse operation. Finally, use the S byte substitution inverse operation to perform byte substitution decryption on each byte of the group. After 11 rounds of decryption, the plaintext binary data is obtained, and finally the plaintext binary array is converted into the byte stream of the source file. Finally, the generated byte stream is converted into a decrypted file.

10. A method for establishing a private file encryption and decryption tool according to claim 9, characterized in that: The AES key extension specifically includes: First, convert the obtained summary password into a 128-bit binary key, then initialize the key to a 4*4 matrix with 4 bytes per column, and then expand the matrix to generate a 44-column extended key array. The rules of the new key matrix are as follows: If the column index i is not a multiple of 4, the new column is generated by XOR operation of i-4 columns and i-1 columns. If the column index i is a multiple of 4: then first the 4 bytes of the word in the i-1 column are cyclically shifted left by 1 byte, and then each byte of the result is replaced by byte, and then the replacement result is XORed with the current round constant, and then the result is XORed with the word in the i-4 column to generate i-column words, and cyclic expansion is finally generated to generate 44 columns of extended key data.