Mail encryption method, mail decryption method, device and electronic device

By using hash operation to generate encryption parameters on the email client, the email data is encrypted, and the corresponding parameters are used for decryption, which solves the problem of information leakage caused by plain text storage of email data and improves the confidentiality and security of email data. .

CN118473647BActive Publication Date: 2024-10-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410919352.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-10-29
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

Existing email clients store email data in clear text, which can easily be maliciously copied, leading to information leakage and reducing the confidentiality and security of email data.

Method used

By obtaining the email data and email ID of the target account, create a random factor, perform a hash operation combined with the hash seed, generate encryption parameters to encrypt the email data, generate encrypted email data, and use the corresponding decryption parameters for decryption. Ensure data confidentiality and security.

Benefits of technology

It effectively improves the confidentiality and security of email data, prevents information leakage, improves encryption efficiency and complexity, and ensures the integrity and correctness of email content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118473647B_ABST
    Figure CN118473647B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose an email encryption method, an email decryption method, an apparatus and an electronic device. The email encryption method includes: obtaining target email data under a target account and an email identifier for marking the target email data, creating a random factor corresponding to the target account, and obtaining a target string based on the combination of the email identifier and the random factor; obtaining a preset first hash seed, performing a hash operation based on the target string and the first hash seed, and generating a first encryption parameter; obtaining a preset second hash seed, performing a hash operation based on the target string and the second hash seed, and generating a second encryption parameter; encrypting the target email data based on the first encryption parameter and the second encryption parameter to generate encrypted email data; the embodiments of the present disclosure can improve the confidentiality and security of email data, and can be widely used in cloud technology, smart transportation and other scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an email encryption method, an email decryption method, a device and an electronic device. Background Art

[0002] With the development of Internet technology, email has become one of the most widely used Internet applications. Whether it is a business or an individual, information can be interconnected by sending and receiving emails.

[0003] Currently, email clients usually store email data in plain text, which can be easily copied maliciously, thus causing information leakage and reducing the confidentiality and security of email data. Summary of the invention

[0004] The following is a summary of the subject matter of the detailed description of the present disclosure. This summary is not intended to limit the scope of the claims.

[0005] The embodiments of the present disclosure provide an email encryption method, an email decryption method, an apparatus, and an electronic device, which can effectively improve the confidentiality and security of email data.

[0006] On the one hand, an embodiment of the present disclosure provides an email encryption method, including:

[0007] Obtain target email data under a target account and an email identifier for marking the target email data, create a random factor corresponding to the target account, and obtain a target character string based on a combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different;

[0008] Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter;

[0009] Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second encryption parameter, wherein the second hash seed is different from the first hash seed;

[0010] The target mail data is encrypted based on the first encryption parameter and the second encryption parameter to generate encrypted mail data.

[0011] On the other hand, the embodiment of the present disclosure further provides an email encryption device, including:

[0012] A first acquisition module is used to acquire target email data under a target account and an email identifier used to mark the target email data, create a random factor corresponding to the target account, and obtain a target string based on a combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different;

[0013] A first processing module is used to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter;

[0014] A second processing module is used to obtain a preset second Hash seed, perform a Hash operation based on the target character string and the second Hash seed, and generate a second encryption parameter, wherein the second Hash seed is different from the first Hash seed;

[0015] The encryption module is used to encrypt the target mail data based on the first encryption parameter and the second encryption parameter to generate encrypted mail data.

[0016] Furthermore, the encryption module is specifically used for:

[0017] Segmenting the target mail data to obtain a plurality of target data segments, and determining first count values ​​corresponding to each of the target data segments based on positions of each of the target data segments in the target mail data;

[0018] The second encryption parameter is used as an initial count value and combined with the first count value to obtain a second count value corresponding to each of the target data segments;

[0019] Using the first encryption parameter as an encryption key, encrypt each of the second count values ​​respectively to obtain a first ciphertext corresponding to each of the target data fragments;

[0020] For each of the target mail data, the target data segment is operated with the corresponding first ciphertext to obtain an encrypted data segment, and encrypted mail data is generated according to the plurality of encrypted data segments.

[0021] Furthermore, the encryption module is specifically used for:

[0022] The second encryption parameter is used as an initial count value and combined with each of the first count values ​​to obtain a second count value corresponding to each of the target data segments;

[0023] Alternatively, for each of the target data fragments, the second encryption parameter is used as the initial count value, and is combined with the target count value corresponding to the current target data fragment and the remaining first count values ​​that are smaller than the target count value to obtain the second count value corresponding to the current target data fragment, wherein the target count value is the first count value corresponding to the target data fragment.

[0024] Furthermore, the email encryption device further includes a first authentication module, which is specifically used for:

[0025] Encrypting the second encryption parameter based on the first encryption parameter to obtain a second ciphertext, and encrypting a preset initial data block based on the first encryption parameter to obtain a subkey;

[0026] Performing a hash operation on the plurality of encrypted data fragments based on the subkey to obtain a target ciphertext;

[0027] The target ciphertext and the second ciphertext are operated to obtain a message authentication code, and the message authentication code is added to the encrypted email data.

[0028] Furthermore, the email encryption device further includes a compression module, which is specifically used for:

[0029] Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores a plurality of candidate data segments and encoded data segments corresponding to each of the candidate data segments, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment;

[0030] The original email data under the target account is obtained, a data segment in the original email data that matches the candidate data segment is determined as a segment to be replaced, and the segment to be replaced is replaced with the corresponding encoded data segment to obtain the target email data.

[0031] Furthermore, the email encryption device further includes a training module, which is specifically used for:

[0032] Obtaining first sample email data and email template data under the target account;

[0033] Segmenting the email template data to obtain a plurality of reference data segments, and constructing an initial compression dictionary corresponding to the target account based on the reference data segments;

[0034] The initial compression dictionary is trained based on the first sample email data to obtain the target compression dictionary.

[0035] Furthermore, the first sample email data is obtained from a cache of a terminal that logs into the target account, and the training module is specifically used for:

[0036] Counting the total number of emails in the first sample email data obtained;

[0037] When the total number of emails is less than a preset number threshold, N second sample email data under the target account are pulled from the server, wherein N is greater than or equal to the difference between the number threshold and the total number of emails, and N is a positive integer;

[0038] The initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain the target compression dictionary.

[0039] Furthermore, the first acquisition module is specifically used for:

[0040] Acquire attribute information of the original mail data, wherein the attribute information is used to indicate the attribute of the to-be-replaced segment in the original mail data;

[0041] A target character string is obtained based on the combination of the mail identifier, the random factor and the attribute information.

[0042] Furthermore, when there are multiple segments to be replaced, the first acquisition module is specifically used to:

[0043] Acquire the fragment position of each of the fragments to be replaced in the original mail data, and concatenate multiple fragment positions to obtain the attribute information of the original mail data;

[0044] Alternatively, the number of each of the to-be-replaced segments is obtained, and a plurality of the numbers of segments are concatenated to obtain the attribute information of the original mail data;

[0045] Alternatively, the segment lengths of the segments to be replaced are obtained, and a plurality of the segment lengths are concatenated to obtain the attribute information of the original mail data.

[0046] On the other hand, the embodiment of the present disclosure also provides a mail decryption method, including:

[0047] Obtaining encrypted email data under the target account and an email identifier used to mark the encrypted email data;

[0048] Obtaining a random factor corresponding to the target account, and obtaining a target character string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different;

[0049] Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter;

[0050] Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter, wherein the second hash seed is different from the first hash seed;

[0051] The encrypted mail data is decrypted based on the first decryption parameter and the second decryption parameter to generate target mail data.

[0052] On the other hand, the embodiment of the present disclosure further provides an email decryption device, including:

[0053] A second acquisition module, used to acquire the encrypted email data under the target account and the email identifier used to mark the encrypted email data;

[0054] A third acquisition module is used to acquire a random factor corresponding to the target account, and obtain a target string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different;

[0055] A second processing module is used to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter;

[0056] A third processing module is used to obtain a preset second Hash seed, perform a Hash operation based on the target character string and the second Hash seed, and generate a second decryption parameter, wherein the second Hash seed is different from the first Hash seed;

[0057] The decryption module is used to decrypt the encrypted email data based on the first decryption parameter and the second decryption parameter to generate target email data.

[0058] Furthermore, the email encryption device further includes a second authentication module, which is specifically used for:

[0059] Encrypting the second decryption parameter based on the first decryption parameter to obtain a third ciphertext, and encrypting a preset initial data block based on the first decryption parameter to obtain a subkey;

[0060] Performing a hash operation on the encrypted email data based on the subkey to obtain a target ciphertext;

[0061] Calculating the target ciphertext and the third ciphertext to obtain a reference authentication code;

[0062] When the reference authentication code is consistent with the message authentication code, the target email data is displayed in the display interface; or, when the reference authentication code is inconsistent with the message authentication code, the target email data corresponding to the email identifier is pulled from the server and the pulled target email data is displayed in the display interface.

[0063] Furthermore, the email encryption device further includes a decompression module, which is specifically used for:

[0064] Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores a plurality of candidate data segments and encoded data segments corresponding to each of the candidate data segments, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment;

[0065] The data segment in the target mail data that matches the encoded data segment is replaced with the corresponding candidate data segment to obtain the original mail data.

[0066] On the other hand, an embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned email encryption method or email decryption method when executing the computer program.

[0067] On the other hand, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned email encryption method or email decryption method.

[0068] On the other hand, the embodiment of the present disclosure further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned email encryption method or email decryption method.

[0069] The disclosed embodiment includes at least the following beneficial effects: by obtaining the target email data and email identifier under the target account, and then obtaining the target string based on the email identifier and the random factor combination corresponding to the target account, since the email identifier is unique, the random factor is random, and the random factors corresponding to different target accounts are different, the target strings obtained by combining different email identifiers and random factors are all different, thereby achieving the uniqueness of the target string at both the account level and the email level, so that when different emails of different target accounts are encrypted, they do not affect each other, which can effectively improve the confidentiality and security of the email data. On this basis, different first hash seeds and second hash seeds are used to perform hash operations on the target string respectively, and different first encryption parameters and second encryption parameters can be obtained respectively. Since the hash operation is irreversible, the target string cannot be restored by the first encryption parameter or the second encryption parameter, which can ensure the confidentiality and security of the random factor, and the first encryption parameter and the second encryption parameter can be derived from the target string at the same time, which can not only improve the encryption efficiency, but also improve the complexity of encryption by combining the first encryption parameter and the second encryption parameter, and further improve the confidentiality and security of the email data.

[0070] Other features and advantages of the present disclosure will be set forth in the following description, and in part will be apparent from the description, or may be learned by practicing the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.

[0072] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure;

[0073] Figure 2 An optional flowchart of the email encryption method provided in the embodiment of the present disclosure;

[0074] Figure 3 An optional flow chart of determining encrypted email data and a message authentication code provided in an embodiment of the present disclosure;

[0075] Figure 4 An optional flow chart of training a compression dictionary provided in an embodiment of the present disclosure;

[0076] Figure 5 An optional flowchart of the email decryption method provided in the embodiment of the present disclosure;

[0077] Figure 6A schematic diagram of an optional process for determining a reference authentication code provided in an embodiment of the present disclosure;

[0078] Figure 7 An optional flowchart of the email encryption method provided in the embodiment of the present disclosure;

[0079] Figure 8 An optional flowchart of the email decryption method provided in the embodiment of the present disclosure;

[0080] Fig. 9 An optional structural diagram of an email encryption device provided in an embodiment of the present disclosure;

[0081] Fig.10 An optional structural diagram of an email decryption device provided in an embodiment of the present disclosure;

[0082] Fig.11 A partial structural block diagram of a terminal provided in an embodiment of the present disclosure;

[0083] Fig.12 A partial structural block diagram of a server provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0084] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0085] It should be noted that in various specific embodiments of the present disclosure, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. Among them, the target object can be a user. In addition, when the embodiment of the present disclosure needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present disclosure will be obtained.

[0086] In the embodiments of the present disclosure, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0087] To facilitate understanding of the technical solution provided by the embodiments of the present disclosure, some key terms used in the embodiments of the present disclosure are explained here:

[0088] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.

[0089] Compression ratio is an indicator used to measure the efficiency of data compression. The compression ratio is the ratio between the original data size and the compressed data size. Generally speaking, the larger the compression ratio, the better the compression effect.

[0090] Currently, email clients usually store email data in plain text, which can be easily copied maliciously, thus causing information leakage and reducing the confidentiality and security of email data.

[0091] Based on this, the embodiments of the present disclosure provide an email encryption method, an email decryption method, an apparatus, and an electronic device, which can improve the confidentiality and security of email data.

[0092] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network.

[0093] Exemplarily, during the encryption stage, the terminal 101 can obtain the target email data under the target account sent by the server 102 and the email identifier used to mark the target email data, create a random factor corresponding to the target account, and obtain the target string based on the combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different; obtain a preset first hash seed, perform a hash operation based on the target string and the first hash seed, and generate a first encryption parameter; obtain a preset second hash seed, perform a hash operation based on the target string and the second hash seed, and generate a second encryption parameter, wherein the second hash seed is different from the first hash seed; encrypt the target email data based on the first encryption parameter and the second encryption parameter to generate encrypted email data. During the decryption stage, the terminal 101 can obtain the encrypted email data under the target account and the email identifier used to mark the encrypted email data; obtain the random factor corresponding to the target account, and obtain the target character string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different; obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter; obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter, wherein the second hash seed is different from the first hash seed; decrypt the encrypted email data based on the first decryption parameter and the second decryption parameter to generate the target email data.

[0094] Terminal 101 obtains the target email data and email identifier under the target account, and then obtains the target string based on the email identifier and the random factor combination corresponding to the target account. Since the email identifier is unique, the random factor is random, and the random factors corresponding to different target accounts are different, the target strings obtained by combining different email identifiers and random factors are all different, thereby ensuring the uniqueness of the target string at both the account level and the email level, so that different emails of different target accounts are not affected when being encrypted, which can effectively improve the confidentiality and security of the email data. On this basis, different first hash seeds and second hash seeds are used to perform hash operations on the target string respectively, and different first encryption parameters and second encryption parameters can be obtained respectively. Since the hash operation is irreversible, the target string cannot be restored by the first encryption parameter or the second encryption parameter, which can ensure the confidentiality and security of the random factor, and the first encryption parameter and the second encryption parameter can be derived from the target string at the same time, which can not only improve the encryption efficiency, but also improve the complexity of encryption by combining the first encryption parameter and the second encryption parameter, thereby further improving the confidentiality and security of the email data. During the decryption process, the encrypted email data can be correctly decrypted only when the first decryption parameter used in the decryption process is consistent with the first encryption parameter used in the encryption process, and the second decryption parameter used in the decryption process is consistent with the second encryption parameter used in the encryption process, and the correct email content can be retrieved by correctly decrypting the target email data generated.

[0095] Server 102 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 may also be a node server in a blockchain network.

[0096] The terminal 101 may be a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present disclosure.

[0097] The method provided in the embodiments of the present disclosure can be applied to various scenarios, including but not limited to cloud technology, smart transportation and other scenarios.

[0098] Reference Figure 2 , Figure 2An optional flow chart of an email encryption method provided in an embodiment of the present disclosure, the email encryption method can be executed by a terminal, or by a server, or by a terminal and a server in cooperation, and the email encryption method includes but is not limited to the following steps 201 to 204.

[0099] Step 201: Obtain target email data under the target account and an email identifier used to mark the target email data, create a random factor corresponding to the target account, and obtain a target string based on the combination of the email identifier and the random factor.

[0100] Among them, the target account is usually an email address used to log in to the email service. The email address is also used to send and receive emails. In email-related scenarios, the target account may also be an account identifier associated with the email address. For example, the target account may be a mobile phone number, account name, etc. The target account may also be a social media account associated with the email address, and the email service can be logged in through the social media account; the target account may exist in the form of a string, binary data, or decimal data, etc., which is not limited to this in the embodiments of the present disclosure.

[0101] Among them, the target email data can be plain text data. When the target email data is plain text data, the email content can be viewed through the target email data. The target email data is sensitive data and will not be disclosed to the public. Only authorized accounts can access the target email data. Normally, the target email data and email identifier under the target account can be obtained only after the target account is successfully logged in, which can improve the security of the target email data. Under the target account, the target email data specifically refers to the email data associated with the email address corresponding to the target account. For example, when the recipient or sender of the email is the email address corresponding to the target account, the data of the email is the target email data. The target email data can be obtained from the logged-in target account. The target email data can be obtained from the memory of the terminal of the account, and the target email data is local email data, which is equivalent to the data of the old email. The target email data can also be obtained from the server, and the target email data is equivalent to the data of the new email. For example, the target email data is obtained from the server based on protocols such as IMAP, POP, ActiveSync, Exchange, and corporate email private protocols; the target email data may include email headers, email bodies, email attachments, and other data; the target email data may include one or more forms of data, for example, the target email data may include data in the form of strings, binary data, decimal data, image data, or audio data, which is not limited to the embodiments of the present disclosure.

[0102] It should be noted that for any target email data, that is, corresponding to any email, there is a corresponding email identifier; the email identifier refers to a unique identifier assigned to an email, and the corresponding email can be quickly located through the email identifier; the email identifier can be created by a terminal that logs in to the target account, for example, when the terminal sends a new email or pulls a new email, the terminal will create a corresponding email identifier for the new email; it can also be created by the corresponding email service provider, for example, the email service provider will create a corresponding email identifier for the email, and the terminal that logs in to the target account can obtain the email identifier from the email service provider; the email identifier can exist in the form of a string, binary data, or decimal data, etc., which is not limited to the embodiments of the present disclosure.

[0103] Among them, the random factors created for different target accounts are different, and the random factors are random. The target account and the corresponding random factor will be associated and stored in an encrypted database. For example, the target account and the corresponding random factor are stored in the form of a key-value pair. The encrypted database can be stored in the memory of the terminal that logs in to the target account; only when the target account is successfully logged in can the random factor associated with the target account be read from the encrypted database. The random factor has a high security and can exist in multiple forms; the random factor can exist in the form of a string, binary data, or decimal data, etc., which is not limited to the embodiments of the present disclosure.

[0104] Based on this, the target string is obtained by combining the email identifier and the random factor, which is equivalent to the target string being associated with the unique email identifier and the randomly generated random factor respectively, making the target string difficult to predict and forge, and can effectively improve the complexity and security of the target string.

[0105] Specifically, the target string can be obtained by combining in a variety of ways, for example, performing an XOR operation on the email identifier and the random factor, and then determining the target string based on the XOR result, for example, performing Base64 encoding on the XOR result to obtain the target string. Since the target string is obtained by an XOR operation, the email identifier and the random factor cannot be restored from the target string, thereby improving the security of the random factor. For another example, the concatenation result of the email identifier and the random factor can be used as the target string.

[0106] It should be noted that no matter what form of data the mail identifier originally belongs to, the mail identifier can be represented as binary data. Similarly, no matter what form of data the random factor originally belongs to, the random factor can be represented as binary data. Therefore, performing an XOR operation on the mail identifier and the random factor specifically refers to performing an XOR operation on the binary data corresponding to the mail identifier and the binary data corresponding to the random factor.

[0107] In one possible implementation, multiple different random factors are created for the same target account, each random factor carries time information for indicating the effective time, the random factor and the effective time carried by the random factor are stored in an encrypted database, and the target string is obtained based on the combination of the email identifier and the random factor. Specifically, the target random factor can be determined from the multiple random factors corresponding to the target account based on the sending time and the effective time corresponding to the target email data, and the target string is obtained based on the combination of the email identifier and the target random factor.

[0108] Taking two consecutive days as an example, the random factors created for the target account include Random1 and Random2. The time information carried by Random1 is used to indicate that the effective time is the first day, and the time information carried by Random2 is used to indicate that the effective time is the second day. Whenever the sending time corresponding to the target email data under the target account is obtained on the first day, the corresponding target string is obtained based on the email identifier corresponding to the target email data and Random1. Whenever the sending time corresponding to the target email data under the target account is obtained on the second day, the corresponding target string is obtained based on the email identifier corresponding to the target email data and Random2.

[0109] Step 202: Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter.

[0110] The first hash seed may be in the form of a string, binary data, or decimal data, which is not limited in the embodiment of the present disclosure. For example, the first hash seed may be set to 1.

[0111] Based on this, the first hash seed can be used as a fixed factor or initial hash value in the hash operation. By introducing the first hash seed in the hash operation, the randomness of the hash result can be increased and the probability of hash conflict can be reduced. By setting a confidential first hash seed, the security of the first encryption parameter can be effectively improved.

[0112] Specifically, the first encryption parameter can be generated by a hash operation of the following process: traverse each character in the target string, for any character, multiply the current hash value by the first hash seed and add it to the character value of the current character to obtain a new hash value, if the current character is not the last character in the target string, the newly obtained hash value is determined as the current hash value of the next character, if the current character is the last character in the target string, the newly obtained hash value is determined as the first encryption parameter. The current hash value of the first character in the target string can be set to a first preset value, for example, the first preset value can be 0; wherein the character value of the current character can be the ASCII value or Unicode value of the current character.

[0113] In addition, the first encryption parameter may also be generated by other types of hash operations. For example, the target string and the first hash seed are input into a hash function such as MurmurHash or Jenkins for hash operation to generate the first encryption parameter. This is not limited in the embodiments of the present disclosure.

[0114] Specifically, an optional calculation formula for the first encryption parameter is as follows:

[0115]

[0116] in, is the first encryption parameter, is a random factor, is the mail identifier, is the XOR operation, is the target string, is the first hash seed, is the hash function used to perform the hash operation.

[0117] Step 203: Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second encryption parameter.

[0118] Among them, the second hash seed is different from the first hash seed. The second hash seed can exist in the form of a string, binary data, or decimal data, etc., which is not limited in the embodiment of the present disclosure. For example, the second hash seed can be set to 2.

[0119] Based on this, the second hash seed can be used as a fixed factor or initial hash value in the hash operation. By introducing the second hash seed in the hash operation, the randomness of the hash result can be increased and the probability of hash conflict can be reduced. By setting a confidential second hash seed, the security of the second encryption parameter can be effectively improved. In addition, since the second hash seed is different from the first hash seed, different hash values ​​can be generated for the target string based on different hash seeds, that is, different first encryption parameters and second encryption parameters are generated, which can improve the security of the first encryption parameters and the second encryption parameters.

[0120] Specifically, similar to the generation process of the first encryption parameter, the second encryption parameter can be generated by the hash operation of the following process, traversing each character in the target string, for any character, multiplying the current hash value by the second hash seed and adding it to the character value of the current character to obtain a new hash value, if the current character is not the last character in the target string, the newly obtained hash value is determined as the current hash value of the next character, if the current character is the last character in the target string, the newly obtained hash value is determined as the second encryption parameter. The current hash value of the first character in the target string can be set to the second preset value, for example, the second preset value can be 0; wherein the character value of the current character can be the ASCII value or Unicode value of the current character.

[0121] In addition, the second encryption parameter may also be generated by other types of hash operations. For example, the target string and the second hash seed are input into a hash function such as MurmurHash or Jenkins for hash operation to generate the second encryption parameter. This is not limited in the embodiments of the present disclosure.

[0122] Specifically, an optional calculation formula for the second encryption parameter is as follows:

[0123]

[0124] in, is the second encryption parameter, is a random factor, is the mail identifier, is the XOR operation, is the target string, is the second hash seed, is the hash function used to perform the hash operation.

[0125] Step 204: Encrypt the target email data based on the first encryption parameter and the second encryption parameter to generate encrypted email data.

[0126] Among them, encrypting the target email data specifically refers to converting the target email data in plain text into encrypted email data in cipher text, and the email content in the target email data cannot be directly viewed through the encrypted email data, thereby effectively protecting the privacy and security of the email data. The encrypted email data and the corresponding email identifier can be stored in the memory of the terminal that logs in to the target account.

[0127] Specifically, one of the first encryption parameter and the second encryption parameter can be used as an encryption key, and the other parameter can be used as a variable. The target email data can be encrypted using the encryption key and the variable. By introducing the variable, the same data can generate different ciphertexts each time it is encrypted, thereby enhancing the security of encryption. The first encryption parameter and the second encryption parameter can also be used as encryption keys, and one of the encryption keys can be used to encrypt the target email data, and the encrypted data can be encrypted using the other encryption key to obtain encrypted email data. By performing cascade encryption on the target email data, the security of encryption can be improved.

[0128] Based on this, by obtaining the target email data and email identifier under the target account, and then combining the target string based on the email identifier and the random factor corresponding to the target account, since the email identifier is unique, the random factor is random, and the random factors corresponding to different target accounts are different, the target strings obtained by combining different email identifiers and random factors are all different, thereby achieving the uniqueness of the target string at both the account level and the email level, so that when encrypting different emails for different target accounts, they do not affect each other, which can effectively improve the confidentiality and security of the email data. On this basis, using different first hash seeds and second hash seeds to perform hash operations on the target string respectively, different first encryption parameters and second encryption parameters can be obtained respectively. Since the hash operation is irreversible, the target string cannot be restored by the first encryption parameter or the second encryption parameter, which can ensure the confidentiality and security of the random factor, and the first encryption parameter and the second encryption parameter can be derived from the target string at the same time, which can not only improve the encryption efficiency, but also improve the complexity of encryption by combining the first encryption parameter and the second encryption parameter, further improving the confidentiality and security of the email data.

[0129] In one possible implementation, the email encryption method also includes: when the target email data is the data of an old email, storing the encrypted email data in the memory of the terminal that logs into the target account, and deleting the local email data; or, when the target email data is the data of a new email, storing the encrypted email data in the memory of the terminal that logs into the target account.

[0130] In a possible implementation, the target email data is encrypted based on the first encryption parameter and the second encryption parameter to generate encrypted email data. Specifically, the target email data may be divided into multiple target data fragments, and the first count value corresponding to each target data fragment is determined based on the position of each target data fragment in the target email data; the second encryption parameter is used as an initial count value and combined with the first count value to obtain a second count value corresponding to each target data fragment; the first encryption parameter is used as an encryption key to encrypt each second count value to obtain a first ciphertext corresponding to each target data fragment; for each target email data, the target data fragment is operated with the corresponding first ciphertext to obtain an encrypted data fragment, and the encrypted email data is generated according to the multiple encrypted data fragments.

[0131] It should be noted that no matter what form the target email data originally belongs to, the target email data can be represented as binary data. When the target email data is segmented, the target email data can be segmented in sequence according to a fixed length, and the lengths of the target data segments obtained by segmentation are the same. For example, the target email data is segmented into multiple 128-bit target data segments from beginning to end in sequence. When the total length of the target email data is not a multiple of 128, it is necessary to pad the end of the target email data to ensure that the length of the target email data is a multiple of 128.

[0132] Among them, the first count value corresponding to each target data fragment can be increasing. For example, the first count value corresponding to the first target data fragment in the target email data is 1, and the first count value corresponding to the second target data fragment in the target email data is 2, that is, the difference between the first count values ​​corresponding to two adjacent target data fragments is 1. The difference between the first count values ​​corresponding to two adjacent target data fragments can also be other values, which is not limited to the embodiments of the present disclosure.

[0133] Specifically, the encryption key may be a symmetric key used in a symmetric encryption method, or may be a key in other forms, which is not limited in the embodiments of the present disclosure. Exemplarily, when the encryption key is a symmetric key used in a symmetric encryption method, the second count value and the first encryption parameter as the symmetric key are input into a symmetric encryption function for encryption processing to obtain a first ciphertext, and the symmetric encryption function includes but is not limited to: AES, Serpent or Twofish encryption functions; when the encryption key in the email encryption method is a symmetric key used in a symmetric encryption method, the first decryption parameter in the subsequent email decryption method needs to be the symmetric key used in the symmetric encryption method.

[0134] Specifically, since the first ciphertext is encrypted data, operating the target data segment with the corresponding first ciphertext to obtain the encrypted data segment is equivalent to encrypting the target data segment to obtain the encrypted data segment. Operating the target data segment with the corresponding first ciphertext to obtain the encrypted data segment can specifically be to XOR the target data segment with the corresponding first ciphertext to obtain the encrypted data segment, or to XOR the target data segment with the corresponding first ciphertext and then operate with a preset value to obtain the encrypted data segment, for example, to add or subtract the XOR result from the preset value to obtain the encrypted data segment. The encrypted data segment can also be obtained by other operation methods, which are not limited in the embodiments of the present disclosure.

[0135] Based on this, since both the first encryption parameter and the second encryption parameter are random, the first ciphertext determined based on the first encryption parameter and the second encryption parameter is also random, which can improve the security of the first ciphertext; by segmenting the target email data, and then determining the first count value corresponding to the target data segment through the position of the target data segment in the target email data, the first count value corresponding to each target data segment is different, so the second count values ​​obtained by combining the second encryption parameter and the first count value are different. When encrypting each target data segment, by introducing the second count value, the target data segment is operated with the first ciphertext encrypted by the corresponding second count value, so that the same target data segment can generate different encrypted data segments, increasing the difficulty of pattern recognition, and can improve the encryption strength and encryption efficiency of the target email data.

[0136] In a possible implementation, the second encryption parameter is used as an initial count value and combined with the first count value to obtain the second count value corresponding to each target data fragment. Specifically, the second encryption parameter is used as an initial count value and combined with each first count value to obtain the second count value corresponding to each target data fragment.

[0137] Alternatively, for each target data fragment, the second encryption parameter is used as the initial count value, which is combined with the target count value corresponding to the current target data fragment and the remaining first count values ​​that are smaller than the target count value to obtain the second count value corresponding to the current target data fragment, wherein the target count value is the first count value corresponding to the target data fragment.

[0138] Specifically, the second encryption parameter is used as the initial count value and is combined with each first count value. Specifically, the second encryption parameter and the first count value can be spliced, or the second encryption parameter and the first count value can be added or subtracted, etc., which is not limited in the embodiments of the present disclosure. Exemplarily, the second encryption parameter is 96-bit binary data, the first count value is 32-bit binary data, and the second encryption parameter and the first count value are spliced ​​to obtain a 128-bit second count value, which can improve the security and efficiency of the encryption process.

[0139] Specifically, the second encryption parameter is used as the initial count value, and is combined with the target count value corresponding to the current target data fragment and the remaining first count values ​​that are smaller than the target count value. Specifically, the target count value and the remaining first count values ​​that are smaller than the target count value can be added to obtain a third count value, and then the second encryption parameter and the third count value are concatenated, or the second encryption parameter and the third count value are added or subtracted, etc., and the embodiments of the present disclosure are not limited here.

[0140] Exemplarily, the number of target data fragments is 3, and each target data fragment is 96-bit binary data. The first count value corresponding to the first target data fragment is 1, the first count value corresponding to the second target data fragment is 2, and the first count value corresponding to the third target data fragment is 3. Each first count value is 32-bit binary data. The target count value of the first target data fragment is 1, and the third count value is 1. Then, the first target data fragment is spliced ​​with the current third count value to obtain the second count value corresponding to the first target data fragment; the target count value of the second target data fragment is 2, and the first count value less than the target count value includes 1, so the third count value is 3, and then the second target data fragment is spliced ​​with the current third count value to obtain the second count value corresponding to the second target data fragment; the target count value of the third target data fragment is 3, and the first count value less than the target count value includes 1 and 2, so the third count value is 6, and then the third target data fragment is spliced ​​with the current third count value to obtain the second count value corresponding to the third target data fragment.

[0141] It is worth noting that when determining the second count value corresponding to each target data segment, since the second encryption parameter and the first count value are both known, the second count value corresponding to each target data segment can be determined in parallel, thereby improving encryption efficiency.

[0142] Based on this, since the first count values ​​corresponding to each target data fragment are different, whether the second encryption parameter is combined with each first count value respectively, or the second encryption parameter, the target count value and the remaining first count values ​​smaller than the target count value are combined, the second count values ​​corresponding to each target data fragment are different. When encrypting each target data fragment, by introducing the second count value, the same target data fragment can generate different encrypted data fragments, which increases the difficulty of pattern recognition and can improve the encryption strength and encryption efficiency of the target email data.

[0143] In one possible implementation, the email encryption method also includes: encrypting the second encryption parameter based on the first encryption parameter to obtain a second ciphertext, encrypting the preset initial data block based on the first encryption parameter to obtain a subkey; performing a hash operation on multiple encrypted data fragments based on the subkey to obtain a target ciphertext; performing an operation on the target ciphertext and the second ciphertext to obtain a message authentication code, and adding the message authentication code to the encrypted email data.

[0144] The initial data block may be in the form of a string, binary data, or decimal data, which is not limited in the embodiments of the present disclosure. For example, the initial data block may be a 128-bit binary data block of all 0s, or other data blocks, which is not limited in the embodiments of the present disclosure.

[0145] Specifically, encrypting the second encryption parameter based on the first encryption parameter to obtain the second ciphertext can specifically be using the first encryption parameter as an encryption key, where the encryption key is a symmetric key used in a symmetric encryption method, and inputting the second encryption parameter and the first encryption parameter as the symmetric key into a symmetric encryption function for encryption processing to obtain the second ciphertext. Similarly, encrypting the preset initial data block based on the first encryption parameter to obtain a sub-key can specifically be inputting the initial data block and the first encryption parameter as the symmetric key into a symmetric encryption function for encryption processing to obtain the sub-key, so that the sub-key is generated dependent on the first encryption parameter; for example, symmetric encryption functions include but are not limited to: AES, Serpent or Twofish encryption functions.

[0146] Specifically, the target ciphertext and the second ciphertext are operated to obtain the message authentication code, which can be obtained by performing an XOR operation on the target ciphertext and the second ciphertext, or by performing an XOR operation on the target ciphertext and the second ciphertext and then performing an operation with a preset value to obtain the message authentication code, for example, the XOR result is added to or subtracted from the preset value to obtain the message authentication code. The message authentication code can also be obtained by other operation methods, which are not limited in the embodiments of the present disclosure.

[0147] Specifically, the message authentication code is added to the encrypted email data. Specifically, the message authentication code can be added to the end of the encrypted email data so that the encrypted email data can carry the corresponding message authentication code. The message authentication code can also be added to other locations of the encrypted email data to facilitate the extraction of the message authentication code during the authentication process. The embodiments of the present disclosure are not limited here; for example, a 16-bit message authentication code is added to the end of the encrypted email data.

[0148] Based on this, since the target ciphertext is obtained by performing a hash operation on multiple encrypted data fragments based on the subkey, and since the security of the first encryption parameter is relatively high, the security of the subkey generated by the first encryption parameter is also relatively high, thereby improving the security of the message authentication code. In addition, the message authentication code is obtained by performing an operation on the target ciphertext and the second ciphertext, and the target ciphertext is obtained by encrypting multiple encrypted data fragments with the subkey. Since the subkey and the second ciphertext are confidential, the subkey and the third ciphertext are difficult to predict and difficult to forge, that is, the message authentication code is difficult to predict and difficult to forge. When any encrypted data fragment changes, a completely different target ciphertext can be generated through a hash operation, and then a completely different message authentication code can be obtained. Therefore, the message authentication code can effectively detect whether the email data has been tampered with, and the integrity and correctness of the target email data can be ensured, thereby significantly improving the security of the target email data.

[0149] The process of determining the target ciphertext is described in detail below.

[0150] In one possible implementation, performing hash operations on multiple encrypted data fragments based on subkeys may specifically be performing hash operations on hidden data corresponding to each encrypted data fragment in sequence based on the subkey in the order of arrangement of the encrypted data fragments, such as performing hash operations through a GHASH function to obtain reference hash values ​​corresponding to each encrypted data fragment, wherein since each encrypted data fragment is determined by a corresponding target data fragment, the order of arrangement of each encrypted data fragment is the same as the order of arrangement of each target data fragment.

[0151] The hidden data corresponding to the current encrypted data segment is the XOR result of the current encrypted data segment and the reference hash value corresponding to the previous encrypted data segment, and the target ciphertext is the reference hash value corresponding to the last encrypted data segment.

[0152] In the process of determining the target ciphertext, additional authentication data can be introduced. At this time, a hash operation is performed on the additional authentication data based on the subkey to obtain an additional hash value, and the XOR result of the first encrypted data fragment and the additional hash value is determined as the hidden data corresponding to the first encrypted data fragment.

[0153] In the process of determining the target ciphertext, no additional authentication data may be introduced. Figure 3 , Figure 3 An optional flow chart for determining encrypted email data and a message authentication code is provided for an embodiment of the present disclosure. It is assumed that the target email data is divided into M target data fragments, and M encrypted data fragments can be obtained by encryption. The first encrypted data fragment is determined as the hidden data corresponding to the first encrypted data fragment. A hash operation is performed on the first encrypted data fragment based on a subkey to obtain a first reference hash value.

[0154] In a possible implementation, before obtaining the target email data under the target account and the email identifier used to mark the target email data, the email encryption method also includes: obtaining a target compression dictionary corresponding to the target account; obtaining the original email data under the target account, determining a data segment in the original email data that matches the candidate data segment as a segment to be replaced, and replacing the segment to be replaced with a corresponding encoded data segment to obtain the target email data.

[0155] Among them, the original email data can be plain text data. When the original email data is plain text data, the email content can be viewed through the original email data. The original email data is sensitive data and will not be disclosed to the public. Only authorized accounts can access the original email data.

[0156] Among them, the target compression dictionary is trained based on the sample email data under the target account. The sample email data refers to the historical email data under the target account. The number of sample email data can be one or more. Usually, the sample email data needs to use email data generated recently. For example, the email data generated within a week is used as the sample email data. When the email data generated within a week is too much, the email data generated within a week can be randomly sampled, and the sampled email data can be used as the sample email data, which can improve the timeliness of the target compression dictionary.

[0157] The target compression dictionary stores multiple candidate data segments and the coded data segments corresponding to each candidate data segment. Each coded data segment is unique. The coded data segment can be an index identifier, which is used to indicate the position of the candidate data segment in the target compression dictionary. For example, assuming that the index identifier assigned to the candidate data segment "Welcome to contact anytime" is 42, "Welcome to contact anytime" in the original email data can be replaced with "42". The space occupied by the coded data segment is smaller than the space occupied by the corresponding candidate data segment because the length of the coded data segment is shorter than the length of the corresponding candidate data segment. Therefore, after replacing the to-be-replaced segment in the original email data with the corresponding coded data segment, the space occupied by the data can be significantly reduced.

[0158] Based on this, since the target compression dictionary is trained based on the sample email data under the target account, the target compression dictionary usually contains data fragments that frequently appear in the sample email data. Since the sample email data under different target accounts are usually different, the target compression dictionaries corresponding to different target accounts are different. For any target account, the target compression dictionary can indicate the distribution pattern of the email data under the target account, thereby achieving a better compression ratio; the data fragment matching the candidate data fragment in the original email data is determined as the fragment to be replaced, and the fragment to be replaced is replaced with the corresponding encoded data fragment, which is equivalent to compressing the original email data under the target account through the target compression dictionary, and the target email data with smaller space can be obtained. Subsequently, encrypted email data with smaller space is obtained by encryption. The compression rate of the email data is high, which can effectively save the storage space of the email data.

[0159] Specifically, after the target email data is compressed, the target email data may be stored in a cache of the target account terminal, and the target email data may be subsequently obtained from the cache of the target account terminal.

[0160] The process of determining the target mail data is described in detail below.

[0161] First, the original email data is divided into multiple original data segments. Then, in each original data segment, the data segment matching the candidate data segment is determined as the segment to be replaced, and the remaining data segments are determined as the segment to be optimized. Then, the segment to be replaced is replaced with the corresponding encoded data segment using a dictionary compression method, and the segment to be optimized is compressed using an additional compression method to obtain the target email data. Among them, the additional compression method includes a compression method based on a sliding window search or a finite state entropy coding compression method.

[0162] The test results of the compression effect are described in detail below.

[0163] During the test, a large amount of email data was compressed using the compression methods provided by the embodiment of the present disclosure, related technology 1, and related technology 2, respectively. The compression results are shown in Table 1 below:

[0164]

[0165] Among them, related technology 1 does not use dictionary compression but only uses additional compression method, and related technology 2 uses gzip compression method. It can be seen that the compression method provided by the embodiment of the present disclosure has the highest compression ratio and the best compression effect, and can effectively save the storage space of email data.

[0166] In one possible implementation, before obtaining the target compression dictionary corresponding to the target account, the email encryption method also includes: obtaining first sample email data and email template data under the target account; segmenting the email template data to obtain multiple reference data segments, and constructing an initial compression dictionary corresponding to the target account based on the reference data segments; training the initial compression dictionary based on the first sample email data to obtain the target compression dictionary.

[0167] Among them, the first sample email data belongs to sample email data, the first sample email data refers to the historical email data under the target account, and the email template data refers to the preset email format under the target account. The email template data can usually be used when sending emails with specific content to save time and maintain consistency in email style. For example, the email template data may include greetings, closing words, signatures, links, etc.

[0168] Based on this, in the email data under the target account, the content of the email template data usually appears frequently, and the email template data can be divided into multiple reference data segments, each of which is a data segment with a high frequency of occurrence. Therefore, an initial compression dictionary corresponding to the target account is constructed based on the reference data segments, and then the initial compression dictionary is trained based on the first sample email data. This can save the training time of the compression dictionary, and the target compression dictionary usually contains each reference data segment, so that the target compression dictionary can effectively indicate the distribution pattern of the email data under the target account, ensuring that the email data has a high compression ratio.

[0169] In one possible implementation, the first sample email data is obtained from the cache of the terminal that logs in to the target account, and the initial compression dictionary is trained based on the first sample email data to obtain the target compression dictionary. Specifically, the total number of emails in the first sample email data obtained can be counted; when the total number of emails is less than a preset number threshold, N second sample email data under the target account are pulled from the server, where N is greater than or equal to the difference between the number threshold and the total number of emails, and N is a positive integer; the initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain the target compression dictionary.

[0170] The terminal cache is a high-speed memory, and the server refers to a mail server, which is a server used to send, receive and store emails. The mail server can be a server provided by a public service provider or a private server maintained by an enterprise or an individual.

[0171] It is worth noting that when the total number of emails in the first sample email data is less than the quantity threshold, it means that the number of the first sample email data is too small. If only the first sample email data with too small a number is used to train the initial compression dictionary, the training effect of the compression dictionary will be poor, making it impossible for the trained target compression dictionary to cover the common patterns of the email data under the target account, resulting in the target compression dictionary being unable to effectively indicate the distribution pattern of the email data under the target account, thereby reducing the compression ratio of the email data.

[0172] Based on this, when the total number of emails in the first sample email data is less than the quantity threshold, it is necessary to pull N second sample email data under the target account from the server. The second sample email data also belongs to the sample email data. Since N is greater than or equal to the difference between the quantity threshold and the total number of emails, the total number of the first sample email data and the second sample email data can be greater than or equal to the quantity threshold. Then, the initial compression dictionary is trained based on the first sample email data and the second sample email data, which can ensure that the number of sample data of the compression dictionary is sufficient, thereby improving the training effect of the compression dictionary, so that the trained target compression dictionary can cover the common patterns of email data under the target account, and the target compression dictionary can effectively indicate the distribution law of email data under the target account, thereby improving the compression ratio of the email data.

[0173] For example, reference Figure 4 , Figure 4 An optional flowchart of training a compression dictionary provided in an embodiment of the present disclosure.

[0174] First, the first sample email data under the target account is obtained; then, it is determined whether the total number of emails in the first sample email data is less than the number threshold; when the total number of emails is greater than the number threshold, the initial compression dictionary is trained using the number threshold of the first sample email data to obtain a target compression dictionary; then, the target compression dictionary is stored.

[0175] Alternatively, when the total number of emails is less than the quantity threshold, N second sample email data under the target account are pulled from the server, where N is equal to the difference between the quantity threshold and the total number of emails. If the number of second sample email data in the server is less than N, the server is continuously checked to see if it generates new second sample email data. If so, the new second sample email data is pulled until N second sample email data under the target account are pulled from the server cumulatively; then, an initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain a target compression dictionary; then, the target compression dictionary is stored.

[0176] In a possible implementation, the target string is obtained based on the combination of the mail identifier and the random factor, specifically, the attribute information of the original mail data is obtained; and the target string is obtained based on the combination of the mail identifier, the random factor and the attribute information.

[0177] The attribute information is used to indicate the attributes of the to-be-replaced segments in the original email data. The attribute information may be generated in the process of compressing the original email data based on the target compression dictionary. During the compression process, some data segments in the original email data will be determined as to-be-replaced segments. Since the original email data is not disclosed to the public, the to-be-replaced segments are not disclosed to the public, and the attribute information of the original email data is also not disclosed to the public. The same attribute information can be determined for the same original email data.

[0178] Based on this, the target string is obtained by combining the email identifier, random factors and attribute information, which is equivalent to the target string being related to the unique email identifier, the randomly generated random factor and the attribute information that is not disclosed to the public, thereby linking the encryption process and the compression process of the email data, making the target string more difficult to predict and forge, and can further improve the complexity and security of the target string.

[0179] Specifically, the target string can be obtained by combining in a variety of ways, for example, performing an XOR operation on the email identifier, the random factor, and the attribute information, and then determining the target string based on the XOR result, for example, performing Base64 encoding on the XOR result to obtain the target string. Since the target string is obtained by an XOR operation, the email identifier and the random factor cannot be restored from the target string, thereby improving the security of the random factor. For another example, the concatenation result of the email identifier, the random factor, and the attribute information can be used as the target string.

[0180] It should be noted that no matter what form of data the mail identifier originally belongs to, the mail identifier can be represented as binary data. Similarly, no matter what form of data the random factor originally belongs to, the random factor can be represented as binary data. No matter what form of data the attribute information originally belongs to, the attribute information can be represented as binary data. Therefore, performing an XOR operation on the mail identifier, the random factor and the attribute information specifically refers to performing an XOR operation on the binary data corresponding to the mail identifier, the binary data corresponding to the random factor and the binary data corresponding to the attribute information.

[0181] It is worth noting that after the attribute information of the original email data is generated, the attribute information and the corresponding email identifier can be associated and stored in an encrypted database. The attribute information can only be read from the encrypted database after the target account successfully logs in. The attribute information is highly secure.

[0182] In a possible implementation, when there are multiple fragments to be replaced, the attribute information of the original email data is obtained, specifically, the fragment position of each fragment to be replaced in the original email data is obtained, and the multiple fragment positions are spliced ​​to obtain the attribute information of the original email data; or, the fragment number of each fragment to be replaced is obtained, and the multiple fragment numbers are spliced ​​to obtain the attribute information of the original email data; or, the fragment length of each fragment to be replaced is obtained, and the multiple fragment lengths are spliced ​​to obtain the attribute information of the original email data.

[0183] In the process of compressing the original mail data, the fragment position of the fragment to be replaced in the original mail data can be determined in a variety of ways; the method for determining the fragment position is described in detail below.

[0184] In the first method, the original email data includes multiple original data fragments arranged in sequence, some of the original data fragments are fragments to be replaced, and the arrangement order of the fragments to be replaced in the multiple original data fragments is determined as the fragment positions of the fragments to be replaced in the original email data; for example, the original email data includes 30 original data fragments arranged in sequence, 3 of which are fragments to be replaced. Assuming that the arrangement order of the first fragment to be replaced in the multiple original data fragments is 2, the arrangement order of the second fragment to be replaced in the multiple original data fragments is 12, and the arrangement order of the third fragment to be replaced in the multiple original data fragments is 20, the attribute information obtained by splicing the three fragment positions is 21220.

[0185] In the second method, the original mail data includes a plurality of original data fragments arranged in sequence. The plurality of original data fragments in the original mail data are divided into a plurality of fragment combinations. Some of the original data fragments are fragments to be replaced. The fragments to be replaced are arranged in order in the corresponding fragment combinations to determine the fragment positions of the fragments to be replaced in the original mail data. For example, the original mail data includes 30 original data fragments arranged in sequence, 4 of which are fragments to be replaced. The 30 original data fragments are divided into 3 fragment combinations, each fragment combination includes 10 original data fragments. Assuming that the arrangement order of the first fragment to be replaced in the first fragment combination is 2, the arrangement order of the second fragment to be replaced in the first fragment combination is 5, the arrangement order of the third fragment to be replaced in the second fragment combination is 3, and the arrangement order of the fourth fragment to be replaced in the third fragment combination is 1, the attribute information obtained by splicing the four fragment positions is 2531.

[0186] In addition to the above two methods, the fragment position may also be determined by other methods, which are not limited in the embodiments of the present disclosure.

[0187] In the process of compressing the original email data, the number of segments of the to-be-replaced segments can be determined in the following manner: the original email data includes a plurality of original data segments arranged in sequence; the plurality of original data segments in the original email data are divided into a plurality of segment combinations; some of the original data segments are to-be-replaced segments; and the total number of segments to be replaced in each segment combination is determined as the number of segments to be replaced; for example, the original email data includes 30 original data segments arranged in sequence; the 30 original data segments are divided into 3 segment combinations; each segment combination includes 10 original data segments; assuming that the total number of segments to be replaced contained in the first segment combination is 3, that is, the number of segments corresponding to the first segment combination is 3; the total number of segments to be replaced contained in the second segment combination is 0, that is, the number of segments corresponding to the second segment combination is 0; the total number of segments to be replaced contained in the third segment combination is 2, that is, the number of segments corresponding to the third segment combination is 2; then the attribute information obtained by splicing the three segment positions is 302.

[0188] In the process of compressing the original mail data, the fragment length of the fragment to be replaced can be determined in the following way: the original mail data includes multiple original data fragments arranged in sequence, some of the original data fragments are fragments to be replaced, and the number of bits occupied by each fragment to be replaced when represented as binary data is determined as the fragment length; for example, the original mail data includes 30 original data fragments arranged in sequence, 3 of which are fragments to be replaced. Assuming that the number of bits occupied by the first fragment to be replaced when represented as binary data is 64, that is, the fragment length of the first fragment to be replaced is 64, the number of bits occupied by the second fragment to be replaced when represented as binary data is 128, that is, the fragment length of the second fragment to be replaced is 128, and the number of bits occupied by the third fragment to be replaced when represented as binary data is 32, that is, the fragment length of the third fragment to be replaced is 32, then the attribute information obtained by splicing the four fragment lengths is 6412832.

[0189] Based on this, since the original email data is not open to the public, the fragment position, number of fragments or fragment length of the fragment to be replaced are not open to the public, so that the attribute information of the original email data is not open to the public. The same original email data can determine the same attribute information. The target string is obtained by combining the email identifier, random factors and attribute information, making the target string difficult to predict and forge, which can effectively improve the complexity and security of the target string.

[0190] In a possible implementation, when the number of segments to be replaced is one, the attribute information of the original email data is obtained, specifically, the segment position of the segment to be replaced in the original email data is obtained, and the segment position is determined as the attribute information of the original email data; or, the number of segments of the segment to be replaced is obtained, and the number of segments is determined as the attribute information of the original email data; or, the segment length of the segment to be replaced is obtained, and the segment length is determined as the attribute information of the original email data.

[0191] The method for determining the fragment position, the number of fragments and the fragment length is similar to the above-mentioned determination method and will not be repeated here.

[0192] Based on this, since the original email data is not open to the public, the fragment position, number of fragments or fragment length of the fragment to be replaced are not open to the public, so that the attribute information of the original email data is not open to the public. The same original email data can determine the same attribute information. The target string is obtained by combining the email identifier, random factors and attribute information, making the target string difficult to predict and forge, which can effectively improve the complexity and security of the target string.

[0193] Reference Figure 5 , Figure 5 An optional flow chart of an email decryption method provided in an embodiment of the present disclosure, the email decryption method can be executed by a terminal, or by a server, or by a terminal and a server in cooperation, and the email decryption method includes but is not limited to the following steps 501 to 505.

[0194] Step 501: Obtain the encrypted email data under the target account and the email identifier used to mark the encrypted email data.

[0195] Among them, the encrypted email data is ciphertext data, and the encrypted email data can be encrypted by the above-mentioned email encryption method. The email content in the unencrypted email data cannot be directly viewed through the encrypted email data. The unencrypted email data can be the above-mentioned target email data, thereby effectively protecting the privacy and security of the email data.

[0196] Specifically, the encrypted email data and email identifier can be obtained from the memory of the terminal that logs in to the target account. Normally, the encrypted email data and email identifier under the target account can be obtained only after the target account is successfully logged in, which can improve the security of the encrypted email data.

[0197] In a possible implementation, when the relevant personnel need to operate the email under the target account, when the relevant personnel need to view, forward, reply or edit the email, the encrypted email data corresponding to the email will be obtained, which can improve the confidentiality and security of the email data. For example, after the target account is successfully logged in, the email ID corresponding to the target account can be displayed in the display interface, and the relevant personnel can select a certain email ID in the interface of the email client, and then read the corresponding encrypted email data in the encryption database through the selected email ID, and then the unencrypted email data corresponding to the selected email ID can be displayed in the interface of the email client.

[0198] In another possible implementation, after the target account successfully logs in, all email identifiers corresponding to the target account are selected as email identifiers, and then the corresponding encrypted email data is read from the encryption database through each selected email identifier. Subsequently, all unencrypted email data under the target account can be displayed in the interface of the email client.

[0199] Step 502: Obtain a random factor corresponding to the target account, and obtain a target string based on the combination of the email identifier and the random factor.

[0200] Among them, different target accounts correspond to different random factors, and the random factors can be obtained from an encrypted database. In the encrypted database, the target account and the corresponding random factor are stored in the form of a key-value pair. Therefore, the random factor corresponding to each target account can be obtained from the encrypted database; only when the target account successfully logs in can the random factor associated with the target account be read from the encrypted database, and the security of the random factor is relatively high.

[0201] Specifically, the method of determining the target character string is the same as the method of determining the target character string in the above-mentioned email encryption method, and will not be described in detail here.

[0202] Step 503: Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter.

[0203] Specifically, the method of generating the first decryption parameter is the same as the method of determining the first encryption parameter in the above-mentioned email encryption method, which will not be repeated here; only when the first hash seed used in the email decryption method is consistent with the first hash seed used in the above-mentioned email encryption method, and the target string used in the email decryption method is consistent with the target string used in the above-mentioned email encryption method, can a first decryption parameter consistent with the first encryption parameter be generated.

[0204] Step 504: Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter.

[0205] The second hash seed is different from the first hash seed.

[0206] Specifically, the method of generating the second decryption parameter is the same as the method of determining the second encryption parameter in the above-mentioned email encryption method, which will not be repeated here; only when the second hash seed used in the email decryption method is consistent with the second hash seed used in the above-mentioned email encryption method, and the target string used in the email decryption method is consistent with the target string used in the above-mentioned email encryption method, can a second decryption parameter consistent with the second encryption parameter be generated.

[0207] Step 505: Decrypt the encrypted email data based on the first decryption parameter and the second decryption parameter to generate target email data.

[0208] It should be noted that, when the encryption key in the above-mentioned email encryption method is the symmetric key used in the symmetric encryption method, the first decryption parameter needs to be the symmetric key used in the symmetric encryption method. In the current case, only when the first decryption parameter used in the email decryption method is consistent with the first encryption parameter used in the above-mentioned email encryption method, and the second decryption parameter used in the email decryption method is consistent with the second encryption parameter used in the above-mentioned email encryption method, can the correct target email data be generated. When the first decryption parameter is inconsistent or the second decryption parameter is inconsistent, the encrypted email data cannot be correctly decrypted, which can improve the security of the email data.

[0209] The decryption process is described in detail below.

[0210] First, the encrypted email data can be divided into a plurality of encrypted data segments, and the number of the encrypted data segments is consistent with the number of target data segments obtained by segmentation in the email encryption method.

[0211] Then, based on the encrypted data fragment, a first count value consistent with the email encryption method can be determined. Assuming that the second decryption parameter is consistent with the second encryption parameter, the first decryption parameter is used as the encryption key to encrypt the combination of the first count value and the second decryption parameter, and a first ciphertext consistent with the email encryption method can be obtained.

[0212] Then, assuming that the encrypted data segment in the email encryption method is obtained by XORing the target data segment with the corresponding first ciphertext, then the currently determined encrypted data segment is XORed with the corresponding first ciphertext to obtain the target data segment, and then the target email data is determined based on each target data segment.

[0213] Based on this, the email decryption method and the above-mentioned email encryption method are based on the same inventive concept, and email data is stored in ciphertext form, which can avoid information leakage, improve the confidentiality of email data, and also improve the security of email data; when the email data needs to be read, it is decrypted by the email decryption method, specifically by obtaining the encrypted email data and the email identifier under the target account, and then obtaining the target string based on the combination of random factors corresponding to the email identifier and the target account, and then using different first hash seeds and second hash seeds to perform hash operations on the target string respectively, which can obtain different first encryption parameters and second encryption parameters, and then decrypt the encrypted email data based on the first encryption parameters and the second encryption parameters to generate target email data. When the first decryption parameter used in the email decryption method is consistent with the first encryption parameter used in the above-mentioned email encryption method, and the second decryption parameter used in the email decryption method is consistent with the second encryption parameter used in the above-mentioned email encryption method, the encrypted email data can be correctly decrypted, and the correct email content can be retrieved by correctly decrypting the generated target email data.

[0214] In one possible implementation, when the target email data is not compressed data, the encrypted email data carries a message authentication code, and the email decryption method also includes: encrypting the second decryption parameter based on the first decryption parameter to obtain a third ciphertext, and encrypting the preset initial data block based on the first decryption parameter to obtain a sub-key; performing a hash operation on the encrypted email data based on the sub-key to obtain a target ciphertext; performing an operation on the target ciphertext and the third ciphertext to obtain a reference authentication code; when the reference authentication code is consistent with the message authentication code, displaying the target email data in a display interface; or, when the reference authentication code is inconsistent with the message authentication code, pulling the target email data corresponding to the email identifier from the server, and displaying the pulled target email data in the display interface.

[0215] The display interface is the interface of the terminal for logging into the target account. Usually, the terminal will be deployed with an email client. In this case, the display interface may be the interface of the email client.

[0216] Specifically, the method for determining the third ciphertext is the same as the method for determining the second ciphertext in the above-mentioned email encryption method, the method for determining the subkey is the same as the method for determining the subkey in the above-mentioned email encryption method, the method for determining the target ciphertext is the same as the method for determining the target ciphertext in the above-mentioned email encryption method, and the method for determining the reference authentication code is the same as the method for determining the message authentication code in the above-mentioned email encryption method, which will not be repeated here.

[0217] Specifically, based on the length of the message authentication code and the method of adding the message authentication code, the encrypted email data and the message authentication code can be determined in the combination result of the encrypted email data and the message authentication code. For example, assuming that the message authentication code is 16-bit data and the message authentication code is spliced ​​at the end of the encrypted email data, the last 16 bits of the combination result of the encrypted email data and the message authentication code can be used as the message authentication code, and the remaining data can be used as the encrypted email data.

[0218] Based on this, since the reference authentication code is determined by the target ciphertext and the third ciphertext, and the target ciphertext is obtained by encrypting the encrypted email data with the subkey, the target ciphertext can be specifically obtained by encrypting multiple encrypted data fragments in the encrypted email data with the subkey. Since the subkey and the third ciphertext are confidential, the subkey and the third ciphertext are difficult to predict and forge. When any encrypted data fragment changes, a completely different target ciphertext can be generated through hash operation, and then a completely different reference authentication code can be obtained.

[0219] On this basis, when the reference authentication code and the message authentication code are consistent, it can be considered that the encrypted email data has not been tampered with, and the target email data is displayed in the display interface of the terminal that logs in to the target account. There is no need to pull the target email data from the server, which can reduce the interaction between the terminal and the server and improve processing efficiency; when the reference authentication code and the message authentication code are inconsistent, it can be considered that the encrypted email data has been tampered with, and it is necessary to delete the encrypted email data in the memory of the terminal that logs in to the target account, and then pull the target email data corresponding to the email identifier from the server. The pulled target email data is email data that has not been tampered with, and then the pulled target email data is displayed in the display interface, which can ensure the integrity and correctness of the displayed target email data, thereby significantly improving the security of the target email data.

[0220] Specifically, refer to Figure 6 , Figure 6 An optional process diagram for determining a reference authentication code provided in an embodiment of the present disclosure is provided. The process for determining the reference authentication code is similar to the process for determining the message authentication code. Therefore, if each encrypted data fragment has not been tampered with, and the first decryption parameter is consistent with the first encryption parameter, and the second decryption parameter is consistent with the second encryption parameter, a reference authentication code consistent with the message authentication code can be obtained.

[0221] In a possible implementation, when the target email data is compressed data, the email decryption method further includes: obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is trained based on sample email data under the target account, and the target compression dictionary stores multiple candidate data segments and encoded data segments corresponding to each candidate data segment, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment; replacing the data segment in the target email data that matches the encoded data segment with the corresponding candidate data segment to obtain the original email data.

[0222] Specifically, the target compression dictionary is consistent with the target compression dictionary used in the above-mentioned email encryption method, and will not be described in detail here.

[0223] Based on this, since the target compression dictionary corresponding to each target account is usually inconsistent, it is necessary to use the target compression dictionary corresponding to the target account to replace the data segment in the target email data that matches the encoded data segment with the corresponding candidate data segment, so that the target email data can be decompressed back to the original email data. When the original email data is plain text data, the email content can be viewed through the original email data.

[0224] It should be noted that when decompressing the target email data, it is also necessary to perform decompression processing according to the decompression method corresponding to the compression method specifically used in the email encryption method.

[0225] In a possible implementation, the target string is obtained based on the combination of the mail identifier and the random factor, specifically, the attribute information of the original mail data is obtained; and the target string is obtained based on the combination of the mail identifier, the random factor and the attribute information.

[0226] Based on this, the attribute information generated in the above-mentioned email encryption method and the corresponding email identifier can be associated and stored in the encryption database. Therefore, the attribute information of the original email data can be read from the encryption database through the email identifier, and then the target string can be obtained based on the email identifier, the random factor and the attribute information combination. This is equivalent to the target string being respectively associated with the unique email identifier, the randomly generated random factor and the attribute information that is not disclosed to the public, making the target string difficult to predict and forge, which can effectively improve the complexity and security of the target string.

[0227] In a possible implementation, when the target email data is obtained by compressing the original email data, the encrypted email data carries a message authentication code, and the email decryption method further includes:

[0228] Encrypting the second decryption parameter based on the first decryption parameter to obtain a third ciphertext, and encrypting the preset initial data block based on the first decryption parameter to obtain a subkey;

[0229] Perform hash operation on the encrypted email data based on the subkey to obtain the target ciphertext;

[0230] The target ciphertext and the third ciphertext are operated to obtain a reference authentication code;

[0231] When the reference authentication code is consistent with the message authentication code, the target email data is decompressed into original email data based on the target compression dictionary, and the original email data is displayed in the display interface; or, when the reference authentication code is inconsistent with the message authentication code, the original email data corresponding to the email identifier is pulled from the server, and the pulled original email data is displayed in the display interface.

[0232] Based on this, by judging whether the reference authentication code is consistent with the message authentication code, the decompressed original email data is displayed when the reference authentication code is consistent with the message authentication code. There is no need to pull the original email data from the server, which can reduce the interaction between the terminal and the server and improve processing efficiency. When the reference authentication code is inconsistent with the message authentication code, the pulled original email data is displayed, which can ensure the integrity and correctness of the displayed original email data, thereby significantly improving the security of the original email data.

[0233] The complete process of email encryption and decryption is described in detail below.

[0234] The following is a detailed description of the email encryption method. Figure 7 , Figure 7 An optional flowchart of the email encryption method provided in the embodiment of the present disclosure.

[0235] First, first sample email data and email template data under a target account are obtained; the email template data is segmented to obtain a plurality of reference data segments, and an initial compression dictionary corresponding to the target account is constructed based on the reference data segments; the total number of emails in the obtained first sample email data is counted; when the total number of emails is less than a preset number threshold, N second sample email data under the target account are pulled from a server, wherein N is greater than or equal to the difference between the number threshold and the total number of emails, and N is a positive integer; the initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain a target compression dictionary.

[0236] Then, a target compression dictionary corresponding to the target account is obtained, wherein the target compression dictionary is trained based on sample email data under the target account, and the target compression dictionary stores multiple candidate data segments and encoded data segments corresponding to each candidate data segment, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment;

[0237] Then, the original email data under the target account is obtained, and the data segment matching the candidate data segment in the original email data is determined as the segment to be replaced, and the segment to be replaced is replaced with the corresponding encoded data segment to obtain the target email data, which is equivalent to compressing the original email data into the target email data based on the target compression dictionary; wherein the original email data can be obtained from the email data stored in the memory of the terminal, and the email data stored in the memory of the terminal is equivalent to the data of the old email; the original email data can also be obtained from the email data pulled from the server, for example, the target email data is obtained from the server based on protocols such as IMAP, POP, ActiveSync, Exchange, and enterprise email private protocols, and the email data pulled from the server is equivalent to the data of the new email;

[0238] Then, the target email data under the target account and the email identifier used to mark the target email data are obtained, and a random factor corresponding to the target account is created, wherein the random factors created for different target accounts are different.

[0239] Then, the fragment position of each to-be-replaced fragment in the original mail data is obtained, and multiple fragment positions are concatenated to obtain the attribute information of the original mail data; or, the fragment number of each to-be-replaced fragment is obtained, and multiple fragment numbers are concatenated to obtain the attribute information of the original mail data; or, the fragment length of each to-be-replaced fragment is obtained, and multiple fragment lengths are concatenated to obtain the attribute information of the original mail data; wherein the attribute information is used to indicate the attribute of the to-be-replaced fragment in the original mail data; and the target character string is obtained based on the mail identifier, the random factor and the attribute information combination.

[0240] Then, obtain the preset first hash seed, perform a hash operation based on the target string and the first hash seed, and generate a first encryption parameter, which is equivalent to generating the first encryption parameter based on the email identifier, the random factor and the first hash seed; obtain the preset second hash seed, perform a hash operation based on the target string and the second hash seed, and generate a second encryption parameter, which is equivalent to generating the second encryption parameter based on the email identifier, the random factor and the second hash seed, wherein the second hash seed is different from the first hash seed.

[0241] Then, the target mail data is segmented to obtain a plurality of target data segments, and the first count value corresponding to each target data segment is determined based on the position of each target data segment in the target mail data; the second encryption parameter is used as the initial count value and is combined with each first count value to obtain the second count value corresponding to each target data segment; or, for any one of the plurality of target data segments, the second encryption parameter is used as the initial count value and is combined with the target count value corresponding to the target data segment and the remaining first count values ​​that are smaller than the target count value to obtain the second count value corresponding to the current target data segment, wherein the target count value is the first count value corresponding to the target data segment; the first encryption parameter is used as the encryption key to encrypt each second count value to obtain the first ciphertext corresponding to each target data segment; for each target mail data, the target data segment is operated with the corresponding first ciphertext to obtain an encrypted data segment, and encrypted mail data is generated according to the plurality of encrypted data segments, which is equivalent to encrypting the target mail data based on the first encryption parameter and the second encryption parameter to generate encrypted mail data.

[0242] Then, the second encryption parameter is encrypted based on the first encryption parameter to obtain the second ciphertext, and the preset initial data block is encrypted based on the first encryption parameter to obtain the subkey; a hash operation is performed on multiple encrypted data fragments based on the subkey to obtain the target ciphertext; the target ciphertext and the second ciphertext are operated to obtain a message authentication code, and the message authentication code is added to the encrypted email data.

[0243] Then, determine whether the original email data is the data of an old email. When the original email data is not the data of an old email, store the encrypted email data in the memory of the terminal that logs in to the target account; or, when the original email data is the data of an old email, delete the original email data from the memory of the terminal that logs in to the target account, and store the encrypted email data in the memory of the terminal that logs in to the target account.

[0244] The following is a detailed description of the email decryption method. Figure 8 , Figure 8 An optional flowchart of the email decryption method provided in the embodiment of the present disclosure.

[0245] First, obtain the encrypted email data under the target account and the email identifier used to mark the encrypted email data, wherein the encrypted email data carries a message authentication code; obtain the random factor corresponding to the target account, and obtain the target character string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different; obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter, which is equivalent to generating the first decryption parameter based on the email identifier, the random factor and the first hash seed; obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter, wherein the second hash seed is different from the first hash seed; decrypt the encrypted email data based on the first decryption parameter and the second decryption parameter to generate the target email data; if the decryption of the encrypted email data fails, it can be considered that the email data has been tampered with and the local email data is not trusted. At this time, it is necessary to pull the target email data corresponding to the email identifier from the server and display the pulled target email data in the display interface.

[0246] Then, the second decryption parameter is encrypted based on the first decryption parameter to obtain a third ciphertext, and the preset initial data block is encrypted based on the first decryption parameter to obtain a subkey; a hash operation is performed on the encrypted email data based on the subkey to obtain a target ciphertext; the target ciphertext and the third ciphertext are operated to obtain a reference authentication code;

[0247] Then, when the reference authentication code is consistent with the message authentication code, it is equivalent to a successful verification, and the target email data is decompressed into the original email data based on the target compression dictionary, and the original email data is displayed in the display interface; or, when the reference authentication code is inconsistent with the message authentication code, it is equivalent to a failed verification, and it can be considered that the email data has been tampered with, and the local email data is not trusted. At this time, the original email data corresponding to the email identifier is pulled from the server, and the pulled original email data is displayed in the display interface.

[0248] Based on this, by obtaining the target email data and email identifier under the target account, and then combining the target string based on the email identifier and the random factor corresponding to the target account, since the email identifier is unique, the random factor is random, and the random factors corresponding to different target accounts are different, the target strings obtained by combining different email identifiers and random factors are all different, thereby achieving the uniqueness of the target string at both the account level and the email level, so that when encrypting different emails for different target accounts, they do not affect each other, which can effectively improve the confidentiality and security of the email data. On this basis, using different first hash seeds and second hash seeds to perform hash operations on the target string respectively, different first encryption parameters and second encryption parameters can be obtained respectively. Since the hash operation is irreversible, the target string cannot be restored by the first encryption parameter or the second encryption parameter, which can ensure the confidentiality and security of the random factor, and the first encryption parameter and the second encryption parameter can be derived from the target string at the same time, which can not only improve the encryption efficiency, but also improve the complexity of encryption by combining the first encryption parameter and the second encryption parameter, further improving the confidentiality and security of the email data. During the decryption process, the encrypted email data can be correctly decrypted only when the first decryption parameter used in the decryption process is consistent with the first encryption parameter used in the encryption process, and the second decryption parameter used in the decryption process is consistent with the second encryption parameter used in the encryption process, and the correct email content can be retrieved by correctly decrypting the target email data generated.

[0249] It can be seen that the email encryption method and email decryption method provided by the embodiments of the present disclosure can be applied to a variety of scenarios.

[0250] For example, it can be applied to email clients deployed locally. The email data under the target account can be compressed and decompressed, which can effectively improve the confidentiality and security of email data. When relevant personnel need to view the original email data, they can quickly decrypt and decompress the encrypted email data. For relevant personnel, the data decryption and decompression process is seamless, which can ensure the user experience.

[0251] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.

[0252] Reference Fig. 9 , Fig. 9 This is an optional structural diagram of an email encryption device provided in an embodiment of the present disclosure. The email encryption device 900 includes:

[0253] The first acquisition module 901 is used to acquire target email data under the target account and an email identifier used to mark the target email data, create a random factor corresponding to the target account, and obtain a target string based on the combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different;

[0254] The first processing module 902 is used to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter;

[0255] The second processing module 903 is used to obtain a preset second Hash seed, perform a Hash operation based on the target character string and the second Hash seed, and generate a second encryption parameter, wherein the second Hash seed is different from the first Hash seed;

[0256] The encryption module 904 is used to encrypt the target email data based on the first encryption parameter and the second encryption parameter to generate encrypted email data.

[0257] Furthermore, the encryption module 904 is specifically used for:

[0258] Segmenting the target mail data to obtain a plurality of target data segments, and determining first count values ​​corresponding to each target data segment based on a position of each target data segment in the target mail data;

[0259] The second encryption parameter is used as an initial count value and combined with the first count value to obtain a second count value corresponding to each target data segment;

[0260] Using the first encryption parameter as an encryption key, encrypt each second count value respectively to obtain a first ciphertext corresponding to each target data segment;

[0261] For each target mail data, the target data segment is operated with the corresponding first ciphertext to obtain an encrypted data segment, and the encrypted mail data is generated according to the multiple encrypted data segments.

[0262] Furthermore, the encryption module 904 is specifically used for:

[0263] The second encryption parameter is used as an initial count value and combined with each first count value to obtain a second count value corresponding to each target data segment;

[0264] Alternatively, for any one of the multiple target data fragments, the second encryption parameter is used as the initial count value, which is combined with the target count value corresponding to the target data fragment and the remaining first count values ​​which are smaller than the target count value to obtain the second count value corresponding to the current target data fragment, wherein the target count value is the first count value corresponding to the target data fragment.

[0265] Furthermore, the email encryption device further includes a first authentication module (not shown in the figure), which is specifically used for:

[0266] Encrypting the second encryption parameter based on the first encryption parameter to obtain a second ciphertext, and encrypting the preset initial data block based on the first encryption parameter to obtain a subkey;

[0267] Perform hash operations on multiple encrypted data fragments based on the subkey to obtain the target ciphertext;

[0268] The target ciphertext and the second ciphertext are operated to obtain a message authentication code, and the message authentication code is added to the encrypted email data.

[0269] Furthermore, the email encryption device further includes a compression module (not shown in the figure), which is specifically used for:

[0270] Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores multiple candidate data segments and encoded data segments corresponding to each candidate data segment, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment;

[0271] The original email data under the target account is obtained, the data segment in the original email data that matches the candidate data segment is determined as the segment to be replaced, and the segment to be replaced is replaced with the corresponding encoded data segment to obtain the target email data.

[0272] Furthermore, the email encryption device further includes a training module (not shown in the figure), which is specifically used for:

[0273] Obtain the first sample email data and email template data under the target account;

[0274] The email template data is segmented to obtain multiple reference data segments, and an initial compression dictionary corresponding to the target account is constructed based on the reference data segments;

[0275] The initial compression dictionary is trained based on the first sample email data to obtain a target compression dictionary.

[0276] Furthermore, the first sample email data is obtained from the cache of the terminal that logs into the target account. The above training module is specifically used for:

[0277] Count the total number of emails in the first sample email data obtained;

[0278] When the total number of emails is less than the preset number threshold, N second sample email data under the target account are pulled from the server, where N is greater than or equal to the difference between the number threshold and the total number of emails, and N is a positive integer;

[0279] The initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain a target compression dictionary.

[0280] Furthermore, the first acquisition module 901 is specifically used for:

[0281] Acquire attribute information of the original mail data, wherein the attribute information is used to indicate the attribute of the segment to be replaced in the original mail data;

[0282] The target string is obtained based on the combination of the email ID, random factor and attribute information.

[0283] Further, when there are multiple segments to be replaced, the first acquisition module 901 is specifically used to:

[0284] Obtaining the fragment position of each to-be-replaced fragment in the original mail data, and concatenating multiple fragment positions to obtain attribute information of the original mail data;

[0285] Alternatively, the number of segments of each segment to be replaced is obtained, and multiple numbers of segments are concatenated to obtain the attribute information of the original mail data;

[0286] Alternatively, the length of each segment to be replaced is obtained, and multiple segment lengths are concatenated to obtain the attribute information of the original mail data.

[0287] The above-mentioned email encryption device 900 and the above-mentioned email encryption method are based on the same inventive concept, and obtain the target email data and email identifier under the target account, and then obtain the target string based on the email identifier and the random factor combination corresponding to the target account. Since the email identifier is unique, the random factor is random, and the random factors corresponding to different target accounts are different, the target strings obtained by combining different email identifiers and random factors are all different, thereby achieving the uniqueness of the target string at the account level and the email level at the same time, so that when different emails of different target accounts are encrypted, they will not affect each other, which can effectively improve the confidentiality and security of the email data. On this basis, different first hash seeds and second hash seeds are used to perform hash operations on the target string respectively, and different first encryption parameters and second encryption parameters can be obtained respectively. Since the hash operation is irreversible, the target string cannot be restored by the first encryption parameter or the second encryption parameter, which can ensure the confidentiality and security of the random factor, and the first encryption parameter and the second encryption parameter can be derived from the target string at the same time, which can not only improve the encryption efficiency, but also improve the complexity of encryption by combining the first encryption parameter and the second encryption parameter, and further improve the confidentiality and security of the email data.

[0288] Reference Fig.10 , Fig.10 This is an optional structural diagram of an email decryption device provided in an embodiment of the present disclosure. The email decryption device 1000 includes:

[0289] The second acquisition module 1001 is used to acquire the encrypted email data under the target account and the email identifier used to mark the encrypted email data;

[0290] The third acquisition module 1002 is used to acquire a random factor corresponding to a target account, and obtain a target string based on the combination of the email identifier and the random factor, wherein different target accounts correspond to different random factors;

[0291] The third processing module 1003 is used to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter;

[0292] The fourth processing module 1004 is used to obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter, wherein the second hash seed is different from the first hash seed;

[0293] The decryption module 1005 is used to decrypt the encrypted email data based on the first decryption parameter and the second decryption parameter to generate target email data.

[0294] Furthermore, the email encryption device further includes a second authentication module (not shown in the figure), which is specifically used for:

[0295] Encrypting the second decryption parameter based on the first decryption parameter to obtain a third ciphertext, and encrypting the preset initial data block based on the first decryption parameter to obtain a subkey;

[0296] Perform hash operation on the encrypted email data based on the subkey to obtain the target ciphertext;

[0297] The target ciphertext and the third ciphertext are operated to obtain a reference authentication code;

[0298] When the reference authentication code is consistent with the message authentication code, the target email data is displayed in the display interface; or, when the reference authentication code is inconsistent with the message authentication code, the target email data corresponding to the email identifier is pulled from the server and the pulled target email data is displayed in the display interface.

[0299] Furthermore, the email encryption device further includes a decompression module (not shown in the figure), which is specifically used for:

[0300] Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores multiple candidate data segments and encoded data segments corresponding to each candidate data segment, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment;

[0301] The data segment in the target email data that matches the encoded data segment is replaced with the corresponding candidate data segment to obtain the original email data.

[0302] The above-mentioned email decryption device 1000 and the email decryption method are based on the same inventive concept, and store email data in ciphertext form, which can avoid information leakage, improve the confidentiality of email data, and also improve the security of email data; when the email data needs to be read, it is decrypted by the email decryption method, specifically by obtaining the encrypted email data and the email identifier under the target account, and then obtaining the target string based on the combination of random factors corresponding to the email identifier and the target account, and then using different first hash seeds and second hash seeds to perform hash operations on the target string respectively, which can obtain different first encryption parameters and second encryption parameters, and then decrypt the encrypted email data based on the first encryption parameter and the second encryption parameter to generate the target email data. When the first decryption parameter used in the email decryption method is consistent with the first encryption parameter used in the above-mentioned email encryption method, and the second decryption parameter used in the email decryption method is consistent with the second encryption parameter used in the above-mentioned email encryption method, the encrypted email data can be correctly decrypted, and the correct email content can be retrieved by correctly decrypting the generated target email data.

[0303] The electronic device for executing the above-mentioned email encryption method or email decryption method provided by the embodiment of the present disclosure may be a terminal. Fig.11 , Fig.11 This is a partial structural block diagram of a terminal provided in an embodiment of the present disclosure, and the terminal includes: a camera assembly 1110, a first memory 1120, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a wireless fidelity (WiFi) module 1170, a first processor 1180, and a first power supply 1190. Those skilled in the art can understand that Fig.11 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0304] The camera assembly 1110 can be used to capture images or videos. Optionally, the camera assembly 1110 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and the VR (Virtual Reality) shooting function or other fusion shooting functions.

[0305] The first memory 1120 may be used to store software programs and modules. The first processor 1180 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the first memory 1120 .

[0306] The input unit 1130 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1130 may include a touch panel 1131 and other input devices 1132 .

[0307] The display unit 1140 may be used to display input information or provided information and various menus of the terminal. The display unit 1140 may include a display panel 1141 .

[0308] The audio circuit 1160 , the speaker 1161 , and the microphone 1162 may provide an audio interface.

[0309] The first power source 1190 may be alternating current, direct current, a disposable battery, or a rechargeable battery.

[0310] The number of sensors 1150 may be one or more, and the one or more sensors 1150 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:

[0311] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The first processor 1180 can control the display unit 1140 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting motion data of games or users.

[0312] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The first processor 1180 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0313] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1140. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the first processor 1180 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1140, the first processor 1180 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1140. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0314] The optical sensor is used to collect the ambient light intensity. In one embodiment, the first processor 1180 can control the display brightness of the display unit 1140 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1140 is increased; when the ambient light intensity is low, the display brightness of the display unit 1140 is decreased. In another embodiment, the first processor 1180 can also dynamically adjust the shooting parameters of the camera assembly 1110 according to the ambient light intensity collected by the optical sensor.

[0315] In this embodiment, the first processor 1180 included in the terminal can execute the email encryption method or the email decryption method of the previous embodiment.

[0316] The electronic device for executing the above-mentioned email encryption method or email decryption method provided in the embodiment of the present disclosure may also be a server. Fig.12 , Fig.12 This is a partial structural block diagram of a server provided in an embodiment of the present disclosure. The server may have relatively large differences due to different configurations or performances, and may include one or more second processors 1210 and a second memory 1230, and one or more storage media 1240 (e.g., one or more mass storage devices) storing application programs 1243 or data 1242. Among them, the second memory 1230 and the storage medium 1240 may be short-term storage or persistent storage. The program stored in the storage medium 1240 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the second processor 1210 may be configured to communicate with the storage medium 1240 to execute a series of instruction operations in the storage medium 1240 on the server.

[0317] The server may also include one or more second power supplies 1220, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1260, and / or one or more operating systems 1241, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0318] The second processor 1210 in the server may be configured to execute an email encryption method or an email decryption method.

[0319] The embodiments of the present disclosure further provide a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the email encryption method or email decryption method of the aforementioned embodiments.

[0320] The embodiment of the present disclosure also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned email encryption method or email decryption method.

[0321] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0322] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0323] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood as not including the number, and above, below, within, etc. are understood as including the number.

[0324] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0325] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0326] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0327] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0328] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.

[0329] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present disclosure. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present disclosure.

Claims

1. A mail encryption method, characterized in that: include: Obtain target email data under a target account and an email identifier for marking the target email data, create a random factor corresponding to the target account, and obtain a target character string based on a combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different; Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter; Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second encryption parameter, wherein the second hash seed is different from the first hash seed; Segmenting the target mail data to obtain a plurality of target data segments, and determining first count values ​​corresponding to each of the target data segments based on positions of each of the target data segments in the target mail data; The second encryption parameter is used as an initial count value and combined with the first count value to obtain a second count value corresponding to each of the target data segments; Using the first encryption parameter as an encryption key, encrypt each of the second count values ​​respectively to obtain a first ciphertext corresponding to each of the target data fragments; For each of the target mail data, the target data segment is operated with the corresponding first ciphertext to obtain an encrypted data segment, and encrypted mail data is generated according to the plurality of encrypted data segments.

2. The email encryption method according to claim 1, characterized in that: The combining the second encryption parameter as the initial count value with the first count value to obtain the second count value corresponding to each of the target data segments includes: The second encryption parameter is used as an initial count value and combined with each of the first count values ​​to obtain a second count value corresponding to each of the target data segments; Alternatively, for each of the target data fragments, the second encryption parameter is used as the initial count value, and is combined with the target count value corresponding to the current target data fragment and the remaining first count values ​​that are smaller than the target count value to obtain the second count value corresponding to the current target data fragment, wherein the target count value is the first count value corresponding to the target data fragment.

3. The email encryption method according to claim 1, characterized in that: The email encryption method further includes: Encrypting the second encryption parameter based on the first encryption parameter to obtain a second ciphertext, and encrypting a preset initial data block based on the first encryption parameter to obtain a subkey; Performing a hash operation on the plurality of encrypted data fragments based on the subkey to obtain a target ciphertext; The target ciphertext and the second ciphertext are operated to obtain a message authentication code, and the message authentication code is added to the encrypted email data.

4. The email encryption method according to claim 1, characterized in that: Before obtaining the target email data under the target account and the email identifier used to mark the target email data, the email encryption method further includes: Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores a plurality of candidate data segments and encoded data segments corresponding to each of the candidate data segments, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment; The original email data under the target account is obtained, a data segment in the original email data that matches the candidate data segment is determined as a segment to be replaced, and the segment to be replaced is replaced with the corresponding encoded data segment to obtain the target email data.

5. The email encryption method according to claim 4, characterized in that: Before obtaining the target compression dictionary corresponding to the target account, the email encryption method further includes: Obtaining first sample email data and email template data under the target account; Segmenting the email template data to obtain a plurality of reference data segments, and constructing an initial compression dictionary corresponding to the target account based on the reference data segments; The initial compression dictionary is trained based on the first sample email data to obtain the target compression dictionary.

6. The email encryption method according to claim 5, characterized in that: The first sample email data is obtained from a cache of a terminal that logs into the target account, and the initial compression dictionary is trained based on the first sample email data to obtain the target compression dictionary, including: Counting the total number of emails in the first sample email data obtained; When the total number of emails is less than a preset number threshold, N second sample email data under the target account are pulled from the server, wherein N is greater than or equal to the difference between the number threshold and the total number of emails, and N is a positive integer; The initial compression dictionary is trained based on the first sample email data and the second sample email data to obtain the target compression dictionary.

7. The email encryption method according to claim 4, characterized in that: The step of obtaining a target character string based on the combination of the mail identifier and the random factor includes: Acquire attribute information of the original mail data, wherein the attribute information is used to indicate the attribute of the to-be-replaced segment in the original mail data; A target character string is obtained based on the combination of the mail identifier, the random factor and the attribute information.

8. The email encryption method according to claim 7, characterized in that: When there are multiple segments to be replaced, the step of obtaining the attribute information of the original mail data includes: Acquire the fragment position of each of the fragments to be replaced in the original mail data, and concatenate multiple fragment positions to obtain the attribute information of the original mail data; Alternatively, the number of each of the to-be-replaced segments is obtained, and a plurality of the numbers of segments are concatenated to obtain the attribute information of the original mail data; Alternatively, the segment lengths of the segments to be replaced are obtained, and a plurality of the segment lengths are concatenated to obtain the attribute information of the original mail data.

9. A method for decrypting mail, characterized in that: include: Obtaining encrypted email data under the target account and an email identifier used to mark the encrypted email data; Obtaining a random factor corresponding to the target account, and obtaining a target character string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different; Obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter; Obtain a preset second hash seed, perform a hash operation based on the target character string and the second hash seed, and generate a second decryption parameter, wherein the second hash seed is different from the first hash seed; Dividing the encrypted email data into a plurality of encrypted data segments, and respectively determining a first count value corresponding to each of the encrypted data segments; Using the first decryption parameter as an encryption key, encrypting a combination of the first count value and the second decryption parameter to obtain first ciphertexts corresponding to each of the encrypted data fragments; The encrypted data segments are operated with the corresponding first ciphertexts to obtain target data segments, and target mail data is determined according to each of the target data segments.

10. The mail decryption method according to claim 9, characterized in that: The encrypted email data carries a message authentication code, and the email decryption method further includes: Encrypting the second decryption parameter based on the first decryption parameter to obtain a third ciphertext, and encrypting a preset initial data block based on the first decryption parameter to obtain a subkey; Performing a hash operation on the encrypted email data based on the subkey to obtain a target ciphertext; Calculating the target ciphertext and the third ciphertext to obtain a reference authentication code; When the reference authentication code is consistent with the message authentication code, the target email data is displayed in the display interface; or, when the reference authentication code is inconsistent with the message authentication code, the target email data corresponding to the email identifier is pulled from the server and the pulled target email data is displayed in the display interface.

11. The mail decryption method according to claim 9, characterized in that: The email decryption method further comprises: Obtaining a target compression dictionary corresponding to the target account, wherein the target compression dictionary is obtained by training based on sample email data under the target account, and the target compression dictionary stores a plurality of candidate data segments and encoded data segments corresponding to each of the candidate data segments, and the space occupied by the encoded data segment is smaller than the space occupied by the corresponding candidate data segment; The data segment in the target mail data that matches the encoded data segment is replaced with the corresponding candidate data segment to obtain the original mail data.

12. An email encryption device, characterized in that: include: A first acquisition module is used to acquire target email data under a target account and an email identifier used to mark the target email data, create a random factor corresponding to the target account, and obtain a target string based on a combination of the email identifier and the random factor, wherein the random factors created for different target accounts are different; A first processing module, configured to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first encryption parameter; A second processing module is used to obtain a preset second Hash seed, perform a Hash operation based on the target character string and the second Hash seed, and generate a second encryption parameter, wherein the second Hash seed is different from the first Hash seed; An encryption module is used to divide the target mail data into multiple target data fragments, and determine the first count value corresponding to each target data fragment based on the position of each target data fragment in the target mail data; use the second encryption parameter as an initial count value and combine it with the first count value to obtain the second count value corresponding to each target data fragment; use the first encryption parameter as an encryption key to encrypt each second count value to obtain the first ciphertext corresponding to each target data fragment; for each target mail data, operate the target data fragment with the corresponding first ciphertext to obtain an encrypted data fragment, and generate encrypted mail data according to the multiple encrypted data fragments.

13. A mail decryption device, characterized in that: include: A second acquisition module, used to acquire the encrypted email data under the target account and the email identifier used to mark the encrypted email data; A third acquisition module is used to acquire a random factor corresponding to the target account, and obtain a target string based on the combination of the email identifier and the random factor, wherein the random factors corresponding to different target accounts are different; A second processing module is used to obtain a preset first hash seed, perform a hash operation based on the target character string and the first hash seed, and generate a first decryption parameter; A third processing module is used to obtain a preset second Hash seed, perform a Hash operation based on the target character string and the second Hash seed, and generate a second decryption parameter, wherein the second Hash seed is different from the first Hash seed; The decryption module is used to divide the encrypted email data into multiple encrypted data fragments, and respectively determine the first count value corresponding to each of the encrypted data fragments; use the first decryption parameter as an encryption key to encrypt the combination of the first count value and the second decryption parameter to obtain the first ciphertext corresponding to each of the encrypted data fragments; operate the encrypted data fragments with the corresponding first ciphertext to obtain the target data fragments, and determine the target email data according to each of the target data fragments.

14. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the email encryption method described in any one of claims 1 to 8 is implemented, or the email decryption method described in any one of claims 9 to 11 is implemented.

15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the computer program implements the email encryption method described in any one of claims 1 to 8, or implements the email decryption method described in any one of claims 9 to 11.

16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the email encryption method described in any one of claims 1 to 8, or implements the email decryption method described in any one of claims 9 to 11.

Citation Information

Patent Citations

  • Information storage method, information acquisition method, information storage apparatus, information acquisition apparatus and device

    CN107948152A

  • Industrial control protocol data compression method and device

    CN112019518A

  • Data processing method, data processing device, electronic equipment and medium

    CN112765642A

  • Message key generation method and device, file encryption method and device, file decryption method and device, equipment and medium

    CN115499118A