Data Encryption Method, Apparatus, Storage Medium and Electronic Device
The target plaintext is encrypted through the randomly generated phase conversion key by the user, which solves the problem that the ciphertext cannot be customized by the symmetric encryption algorithm, and realizes the control of ciphertext and the expansion of application scenarios in the symmetric encryption algorithm.
Patent Information
- Application Number
- CN202211190638.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-09-28
AI Technical Summary
The ciphertext obtained by the symmetric encryption algorithm cannot be customized, which makes the ciphertext uncontrollable, limiting the application scenarios of the symmetric encryption algorithm.
By obtaining the randomly generated binary conversion key by the user, encrypting the target plaintext, generating the ciphertext corresponding to the binary conversion key, realizing the customization of the ciphertext.
The ciphertext control in symmetric encryption algorithm is realized, and the application scenario of symmetric encryption algorithm is expanded.
Smart Images

Figure CN115550030B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a data encryption method, a data encryption device, a computer-readable storage medium, and an electronic device. Background Art
[0002] In the field of computer technologies, information encryption and compression are often involved. Currently, common encryption algorithms include symmetric encryption algorithms and asymmetric encryption algorithms. Among them, due to the excessive elements involved in the encryption and decryption processes of the asymmetric encryption algorithm and the overly complex encryption and decryption steps, the application scenarios of the asymmetric encryption algorithm have relatively high limitations. The symmetric encryption algorithm only requires one key to achieve encryption and decryption, and the encryption and decryption steps are relatively simple. However, the ciphertext obtained by symmetric encryption cannot be customized, resulting in uncontrollable ciphertext, and thus it cannot be applied to some specific scenarios.
[0003] It should be noted that the information disclosed in the above background art section is only used to enhance the understanding of the background of the present disclosure, and thus may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0004] The purpose of the present disclosure is to provide a data encryption method, a data encryption device, a computer-readable storage medium, and an electronic device, thereby at least to some extent overcoming the problem that the ciphertext obtained by symmetric encryption cannot be customized, resulting in uncontrollable ciphertext and limiting the application scenarios of the symmetric encryption algorithm.
[0005] According to a first aspect of the present disclosure, there is provided a data encryption method, including:
[0006] Obtaining a base conversion key randomly generated by a user;
[0007] Encrypting a target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
[0008] In an exemplary embodiment of the present disclosure, before encrypting the target plaintext according to the base conversion key, the method further includes:
[0009] Decomposing the target plaintext into first strings of multiple types;
[0010] Converting the first strings of the corresponding types into second strings by using a preset encoding method;
[0011] Converting the target plaintext into a third string according to a preset base conversion order;
[0012] Combining the first strings, the second strings, and the third string to obtain a first base string.
[0013] In an exemplary embodiment of the present disclosure, the base conversion key is a base conversion key with a preset length, and the target attribute includes the key length;
[0014] Encrypting the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key includes:
[0015] Converting the first binary string into a second binary string with a target length according to the base conversion key with the preset length, and using the second binary string as the first ciphertext.
[0016] In an exemplary embodiment of the present disclosure, the base conversion key is a base conversion key containing preset content, and the target attribute includes the key content;
[0017] Encrypting the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key includes:
[0018] Converting the first binary string into the third binary string containing the target content according to the base conversion key containing the preset content, and using the third binary string as the second ciphertext.
[0019] In an exemplary embodiment of the present disclosure, the method further includes:
[0020] Calculating the length of the target plaintext and converting the length of the target plaintext into a fourth binary string;
[0021] Adding the fourth binary string to a target position in the second binary string or the third binary string to obtain a third ciphertext.
[0022] In an exemplary embodiment of the present disclosure, the type of the first string is the first type; converting the first string of the corresponding type into a second string by using a preset encoding method includes:
[0023] Encoding each character in the first string of the first type according to a preset first character mapping table to obtain a plurality of first encoding values;
[0024] Obtaining a first random number generated by a user, and calculating the second string according to each of the first encoding values and the first random number.
[0025] In an exemplary embodiment of the present disclosure, the type of the first string is the second type; converting the first string of the corresponding type into a second string by using a preset encoding method includes:
[0026] Encode each character in the first string of the second type according to a preset second character mapping table to obtain a plurality of second encoding values;
[0027] Concatenate the plurality of second encoding values to obtain the second string.
[0028] In an exemplary embodiment of the present disclosure, the converting the target plaintext into a third string according to a preset base conversion order includes:
[0029] Traverse each character in the target plaintext, convert the characters that meet the target type in the target plaintext into third encoding values, and convert the other characters except the characters of the target type into fourth encoding values;
[0030] Based on the positions of the characters in the target plaintext, form an intermediate base string from the third encoding values and the fourth encoding values;
[0031] Convert the intermediate base string into the third string in the target base.
[0032] In an exemplary embodiment of the present disclosure, the combining the first string, the second string, and the third string to obtain a first base string includes:
[0033] Obtain a second random number generated by the encryption system;
[0034] Combine the first string of the target type, the plurality of second strings obtained by converting the first strings of various types, the third string, and the second random number in a preset order to obtain the first base string.
[0035] According to a second aspect of the present disclosure, there is provided a data encryption device, including:
[0036] A key acquisition module, configured to acquire a base conversion key randomly generated by a user;
[0037] A data encryption module, configured to encrypt the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
[0038] According to a third aspect of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processing unit, the method described in any one of the above is implemented.
[0039] According to a fourth aspect of the present disclosure, there is provided an electronic device, including: a processing unit; a display unit; and a storage unit for storing executable instructions of the processing unit; wherein, the processing unit is configured to execute the method described in any one of the above by executing the executable instructions; the display unit is used to display the ciphertext generated after executing the method described in any one of the above.
[0040] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0041] In the data encryption method provided by the exemplary embodiment of the present disclosure, a radix conversion key randomly generated by a user is obtained; the target plaintext is encrypted according to the radix conversion key to obtain a ciphertext corresponding to the target attribute of the radix conversion key. The present disclosure can achieve the control of ciphertext in the symmetric encryption algorithm, so that the symmetric encryption algorithm can be flexibly applied to more scenarios.
[0042] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
[0044] Figure 1 A schematic diagram of a system architecture to which the data encryption method of the embodiments of the present disclosure can be applied is shown;
[0045] Figure 2 A flowchart of a data encryption method in an embodiment of the present disclosure is schematically shown;
[0046] Figure 3 A flowchart of a data preprocessing in an embodiment of the present disclosure is schematically shown;
[0047] Figure 4 A flowchart of a data conversion in an embodiment of the present disclosure is schematically shown;
[0048] Figure 5 A flowchart of a bitmap conversion in an embodiment of the present disclosure is schematically shown;
[0049] Figure 6 A flowchart of a radix conversion using a radix conversion key in an embodiment of the present disclosure is schematically shown;
[0050] Figure 7Schematically shows a flowchart of another data encryption method in an embodiment of the present disclosure;
[0051] Figure 8 Schematically shows a decryption flowchart in a data encryption method in an embodiment of the present disclosure;
[0052] Figure 9 Schematically shows a block diagram of a data encryption device in an embodiment of the present disclosure;
[0053] Figure 10 Schematically shows a structural diagram of an electronic device suitable for implementing an embodiment of the present disclosure. Detailed implementation manners
[0054] Now, example embodiments will be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art will realize that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be used. In other cases, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0055] In addition, the drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus repeated descriptions thereof will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0056] Figure 1 Shows a schematic diagram of a system architecture of a data encryption method to which an embodiment of the present disclosure can be applied.
[0057] As Figure 1As shown, the system architecture 100 may include one or more of the terminal devices 101, 102, 103, the network 104, and the server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc. The terminal devices 101, 102, 103 may be various electronic devices, including but not limited to desktop computers, portable computers, smartphones, and tablet computers, etc. The server 105 may be a single server, or a server cluster composed of multiple servers, or a virtualization platform or a cloud computing service center. It should be understood that Figure 1 the numbers of the terminal devices, the network, and the server in
[0058] The data encryption method provided by the exemplary embodiments of the present disclosure is generally executed by the server 105. Correspondingly, the data encryption device is generally set in the server 105. For example, after the server 105 receives the base conversion key input by the user through the terminal device 101, it encrypts the target plaintext according to the base conversion key to obtain the ciphertext corresponding to the target attribute of the base conversion key, and sends the ciphertext to the terminal device 101 for display to the user. However, those skilled in the art can easily understand that the data encryption method provided by the exemplary embodiments of the present disclosure can also be executed by one or more of the terminal devices 101, 102, 103. Correspondingly, the data encryption device can also be set in the terminal devices 101, 102, 103. For example, when the terminal device 101 executes the data encryption method and encrypts the target plaintext according to the base conversion key randomly generated by the user to obtain the ciphertext corresponding to the target attribute of the base conversion key, the ciphertext can be directly displayed on the display screen of the terminal device 101 for display to the user. No special limitation is made in this exemplary embodiment.
[0059] The technical solutions of the embodiments of the present disclosure are elaborated in detail below:
[0060] In the exemplary embodiments of the present disclosure, the OCR (optical character recognition) recognition scenario is taken as an example for illustration. Exemplarily, when the ciphertext obtained by using the symmetric encryption algorithm is recognized through the OCR recognition system in the form of a picture, in order to ensure the accuracy of system recognition, it is necessary to constrain the ciphertext. For example, it can be controlled that the ciphertext does not contain easily confused characters, such as the ciphertext cannot contain both the Arabic numeral 1, the lowercase English letter l, and the uppercase English letter I at the same time.
[0061] However, the ciphertext obtained by symmetric encryption currently cannot be customized, resulting in uncontrollable ciphertext, so it cannot be applied to some specific scenarios. For example, in the process of OCR recognition, if the area of the terminal device for displaying the ciphertext is limited and the length of the ciphertext needs to be controlled, or in order to avoid recognition errors, the scenario where the ciphertext does not contain easily confused characters needs to be controlled, or other scenarios where the ciphertext needs to be controlled according to the actual needs of the user, the present disclosure does not make specific limitations on this.
[0062] Based on one or more of the above problems, the present exemplary embodiment provides a data encryption method that can achieve control of the ciphertext in the symmetric encryption algorithm. Refer to Figure 2 As shown, the data encryption method may include steps S210 to S220:
[0063] Step S210. Obtain a base conversion key randomly generated by the user;
[0064] Step S220. Encrypt the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
[0065] In the data encryption method provided by the exemplary embodiment of the present disclosure, by obtaining a base conversion key randomly generated by the user; encrypting the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key. The present disclosure can achieve control of the ciphertext in the symmetric encryption algorithm, so that the symmetric encryption algorithm can be flexibly applied to more scenarios.
[0066] Next, the above steps of the present exemplary embodiment will be described in more detail.
[0067] In step S210, obtain a base conversion key randomly generated by the user.
[0068] In the exemplary embodiment of the present disclosure, a base conversion key randomly generated by the user can be obtained, and the data is symmetrically encrypted using the base conversion key. Among them, the base conversion key is used to perform base conversion on a certain string to achieve encryption of the string. For example, a decimal string can be converted into a 34 - base string according to the base conversion key. Correspondingly, the decimal string is the plaintext, and the 34 - base string is the encrypted ciphertext. For example, a base conversion key randomly generated by the user can be "QGZVCXE012BD".
[0069] It should be noted that the user can randomly generate different base conversion keys according to the actual needs in the application scenario. However, the base conversion keys generated each time in the same application scenario need to meet the same constraint conditions. Among them, the constraint conditions can refer to constraints on attributes such as the length and content of the base conversion key. For example, when the length of the base conversion key is relatively long, the length of the generated ciphertext is relatively short. Conversely, the length of the generated ciphertext is relatively long. For example, in a certain application scenario, it is required that the generated ciphertext does not exceed 5 characters, and the randomly generated base conversion key can be constrained to be no less than 10 characters. It can be understood that the content of the base conversion key generated by the user each time can be different, but all meet the constraint condition of no less than 10 characters to ensure that the generated ciphertext meets the user's requirements.
[0070] After obtaining the base conversion key randomly generated by the user, a piece of plaintext to be encrypted can be selected as the target plaintext, and the target plaintext can be encrypted using the base conversion key. Refer to Figure 3 As shown, before encrypting the target plaintext using the base conversion key, the target plaintext can be preprocessed according to steps S310 to S340.
[0071] Step S310. Decompose the target plaintext into first strings of multiple types.
[0072] In an exemplary implementation, the target plaintext can include one or more types of characters. For example, it can be characters of types such as English letters, Arabic numerals, and special characters. The present disclosure does not make specific limitations in this regard. To improve the security of data, the target plaintext can be decomposed into first strings of multiple types to encrypt various types of first strings in different ways. Exemplarily, when the target plaintext includes three types of characters: English letters, Arabic numerals, and special characters, all the characters in the target plaintext can be decomposed and recombined. All the English letters in the target plaintext form a first string of the English letter type, all the Arabic numerals in the target plaintext form a first string of the Arabic numeral type, and all the special characters in the target plaintext form a first string of the special character type.
[0073] For example, when the target plaintext is "A1+B2 / C3*", the target plaintext can be decomposed into three types of first strings: "ABC", "123", and "+ / *".
[0074] Step S320. Convert the first string of the corresponding type into a second string using a preset encoding method.
[0075] If the target plaintext is decomposed into first strings of multiple types, different types of first strings can be encoded in different ways using a preset encoding method, thereby increasing the difficulty of cracking the ciphertext.
[0076] In an exemplary embodiment, with reference to Figure 4 as shown, the first string of the first type can be encoded according to step S410 and step S420.
[0077] Step S410. Encode each character in the first string of the first type according to a preset first character mapping table to obtain a plurality of first encoding values.
[0078] The first string of the first type can be a first string of the English letter type, a first string of the Arabic numeral type, or a first string of the special character type. The present disclosure does not make specific limitations thereon. The preset encoding method corresponding to the first string of the first type can be ASCII (American Standard Code for Information Interchange) encoding. Correspondingly, a partial preset first character mapping table is shown in Table 1:
[0079] Table 1
[0080] Decimal Octal Hexadecimal Binary Symbol Chinese Explanation 33 041 21 00100001 ! Exclamation Mark 48 060 30 00110000 0 0 65 101 41 01000001 A English Capital Letter A 66 102 41 01000010 B English Capital Letter B
[0081] Table 1 gives the first encoding values corresponding to partial characters of various types, that is, ASCII codes in different bases. Taking the English capital letter A as an example, the decimal ASCII code of the English capital letter A is 65, the octal ASCII code is 101, the hexadecimal ASCII code is 41, and the binary ASCII code is 01000001.
[0082] Exemplarily, the first string of the English letter type is used as the first string of the first type. For example, for the first string "ABC", each English letter in the string can be converted into a decimal ASCII code, and the new string obtained is "656667". In other examples, each English letter in the string can also be converted into ASCII codes in other bases according to the actual needs of the user. The present disclosure does not make limitations thereon.
[0083] Step S420. Obtain a first random number generated by the user, and calculate the second string according to each of the first encoding values and the first random number.
[0084] To further improve the security of data, after converting the first string of the first type into ASCII codes, a first random number generated by the user can be obtained, and a second string can be calculated based on the ASCII codes corresponding to each character and the first random number. It can be understood that the base type of the first random number is the same as that of the ASCII code. Exemplarily, after converting the characters in the first string into ASCII codes, the difference between the ASCII code and the first random number can be calculated, and the obtained difference can be used as the latest encoding value of the character. In other examples, the sum of the ASCII code and the first random number can also be calculated and used as the latest encoding value of the character. The present disclosure does not make any limitations in this regard.
[0085] For example, if the first random number generated by the user is 38, after converting the first string "ABC" into the string "656667", the ASCII code of each character can be subtracted by 38. Based on this, the first string "ABC" is finally converted into the second string "272829".
[0086] In this example, the value subtracted when converting the first string of the first type into ASCII codes is random, and only the user knows this random number. It is not easy for other code breakers to obtain the specific value of this random number, which increases the difficulty of deciphering the ciphertext and thus improves the security of data.
[0087] In another exemplary implementation, if the type of the first string is the second type, such as a first string of a special character type. Each character in the first string of the second type can be encoded according to a preset second character mapping table to obtain a plurality of second encoding values, and the plurality of second encoding values can be concatenated to obtain a second string. Exemplarily, a partial second character mapping table is shown in Table 2 as follows:
[0088] Table 2
[0089]
[0090]
[0091] Table 2 gives the mapping codes of a plurality of special characters, that is, the second encoding values corresponding to each character. For example, the second encoding value of the special character "、" is X, the second encoding value of the special character "!" is Y, and the second encoding value of the special character "@" is 1. It should be noted that the user can customize the second character mapping table according to actual needs, and the present disclosure does not make specific limitations on the mapping relationship in the second character mapping table.
[0092] For example, for the first string "+ / *", the mapping codes corresponding to the special characters in the first string can be obtained according to the second character mapping table shown in Table 2. Specifically, the mapping code of the special character "+" is 7, the mapping code of the special character " / " is 8, and the mapping code of the special character "*" is 9. The corresponding three mapping codes are concatenated according to the positions of the special characters in the first string to obtain the second string "789".
[0093] In this example, by performing character mapping on the first string of the second type, different encoding methods are implemented for different types of first strings, increasing the encryption steps of the entire encryption process and further improving the security of the data.
[0094] Step S330. Convert the target plaintext into a third string according to a preset base conversion order.
[0095] Still taking the target plaintext "A1+B2 / C3*" as an example for illustration, the target plaintext includes three types of characters: English letters, Arabic numerals, and special characters. In one exemplary implementation, the English letter type and the Arabic numeral type can be used as the target types. Referring to Figure 5 as shown, the target plaintext can be converted into a third string according to steps S510 to S530.
[0096] Step S510. Traverse each character in the target plaintext, convert the characters in the target plaintext that conform to the target type into a third encoding value, and convert the other characters except the characters of the target type into a fourth encoding value.
[0097] When the target type is the English letter type, each character in the target plaintext can be traversed, the characters in the target plaintext that are of the English letter type are converted into a third encoding value, and the other characters that are not of the English letter type are converted into a fourth encoding value. For example, for the target plaintext "A1+B2 / C3*", each English letter in the plaintext can be marked with a third encoding value, such as 1, and the other characters except the English letters in the plaintext are marked with a fourth encoding value, such as 0.
[0098] Step S520. Based on the positions of the characters in the target plaintext, form an intermediate base string from the third encoding value and the fourth encoding value.
[0099] The position corresponding to each character in the target plaintext can be composed of a third encoding value and a fourth encoding value to form an intermediate radix string. For example, corresponding to the positions of each character in the target plaintext "A1+B2 / C3*", marking A, B, and C as "1", and marking 1, +, 2, / , 3, and * as "0", the target plaintext "A1+B2 / C3*" can be converted into an intermediate radix string, such as the binary string "100100100".
[0100] Step S530. Convert the intermediate radix string into the third string in the target radix.
[0101] After obtaining the intermediate radix string, the intermediate radix string can be further converted into the third string in the target radix according to a preset radix conversion order. Exemplarily, the preset radix conversion order can be to convert the target plaintext into a binary string and then convert the binary string into the third string in decimal. It should be noted that the present disclosure does not specifically limit the preset radix conversion order, and the user can customize the radix conversion order according to actual needs.
[0102] For example, after converting the target plaintext "A1+B2 / C3*" into the binary string "100100100", the binary string can be converted into the third string in decimal. Among them, in order to prevent the first digit from being 0, a "1" can be concatenated in front of the binary string to obtain a new binary string "1100100100", and after conversion to decimal, the third string "804" is obtained.
[0103] Similarly, when the target type is an Arabic numeral type and the preset radix conversion order is to convert the target plaintext into a binary string and then convert the binary string into the third string in decimal, each character in the target plaintext can be traversed, the characters in the target plaintext that are of the Arabic numeral type are converted into the third encoding value, and the other characters that are not of the Arabic numeral type are converted into the fourth encoding value. For example, for the target plaintext "A1+B2 / C3*", each Arabic numeral in the plaintext can be marked as the third encoding value, such as 1, and the other characters in the plaintext except Arabic numerals are marked as the fourth encoding value, such as 0. Corresponding to the positions of each character in the target plaintext "A1+B2 / C3*", 1, 2, and 3 are marked as "1", and A, +, B, / , C, and * are marked as "0", so that the target plaintext "A1+B2 / C3*" can be converted into the binary string "010010010". When converting the binary string "010010010" into the third string in decimal, similarly, in order to prevent the first digit from being 0, a "1" can be concatenated in front of the binary string to obtain a new binary string "1010010010", and after conversion to decimal, the third string "658" is obtained.
[0104] In this example, steps of bitmap conversion (e.g., marking English letters in the target plaintext as 1 and other characters as 0) and radix conversion are added during the entire encryption process, which not only increases the complexity of the encryption process, but also improves the difficulty of deciphering the ciphertext and enhances the data security.
[0105] Step S340. Combine the first string, the second string, and the third string to obtain a first radix string.
[0106] In the exemplary embodiment of the present disclosure, for the target plaintext "A1+B2 / C3*": ① Three types of first strings, namely "ABC", "123", and "+ / *", can be obtained by decomposing the target plaintext; ② When converting the first string "ABC" to ASCII code, subtract a random number 38 to obtain the second string "272829"; ③ Perform character mapping on the first string "+ / *" to obtain the second string "789"; ④ Perform bitmap conversion on the English letters in the target plaintext to obtain the third string "804"; ⑤ Perform bitmap conversion on the Arabic numerals in the target plaintext to obtain the third string "658". One or more strings generated in ①-⑤ can be combined in a preset order to obtain a first radix string. The present disclosure does not make specific limitations on the specific composition and combination order of the first radix string. Users can select corresponding combination methods according to actual needs to flexibly generate simple or complex first radix strings. For example, the first radix string can be "272829789804" or "804658272829123789", and the present disclosure does not limit this.
[0107] In an exemplary embodiment, to further improve the difficulty of deciphering the ciphertext, a second random number generated by an encryption system can be obtained, and the first string of the target type, multiple second strings obtained by converting various types of first strings, the third string, and the second random number are combined in a preset order to obtain a first radix string.
[0108] Exemplarily, for the target plaintext "A1+B2 / C3*", for the convenience of base conversion, the first string of the target type selected can be the first string of the Arabic numeral type "123". The multiple second strings obtained by converting the first strings of various types are successively "272829" and "789". The third strings corresponding to the English letter bitmap conversion and the Arabic numeral bitmap conversion are "804" and "658". The second random number generated by the encryption system is "456". The user can customize the preset order to combine the Arabic numeral type string "123", the ASCII code "272829", the special character mapping string "789", the English letter bitmap conversion string "804", the Arabic numeral bitmap conversion string "658", and the second random number "456" into the first base string according to this preset order. For example, the first base string can be "456804658272829123789".
[0109] In step S220, encrypt the target plaintext according to the base conversion key to obtain the ciphertext corresponding to the target attribute of the base conversion key.
[0110] In an example implementation, the base conversion key randomly generated by the user can be a base conversion key of a preset length, and the corresponding target attribute can be the key length. Exemplarily, the first base string can be converted into a second base string of a target length according to the base conversion key of the preset length, and the second base string is used as the first ciphertext. Among them, the user can customize the length of the base conversion key, thereby controlling the target length of the generated second base string.
[0111] For example, when the generated first base string is "456804658272829123789", a base conversion key with a preset length greater than 20 characters can be generated, such as "QGZVCXE012BDF345GHJ6K7L8M9NPSRUAWY", to generate a second base string "ZMHBLY5VA1CEF4" with a target length less than 15 characters. In this example, the first base string is a decimal string, and the second base string is a 34-base string. It can be understood that the present disclosure does not limit the specific base conversion, that is, the first base string can be converted into a second base string of any base.
[0112] In this example, the first binary string is a large integer, and the corresponding binary conversion process is relatively complex. Therefore, to facilitate the explanation of the process of converting the first binary string into the second binary string using the binary conversion key, the first binary string "7896" can be taken as an example for illustration, and the binary conversion key is still "QGZVCXE012BDF345GHJ6K7L8M9NPSRUAWY". Specifically, referring to Figure 6 as shown, the first binary string "7896" can be converted into a 34 - bit second binary string according to steps S601 to S608 using the binary conversion key.
[0113] Step S601. Define a character splicer;
[0114] Step S602. Determine if m > 34 - 1: If m > 34 - 1, execute step S603; if m < 34 - 1, then execute step S606. When m = 7896, since m > 34 - 1, step S603 is executed;
[0115] Step S603. Calculate m / 34;
[0116] Step S604. Select the character in the binary conversion key corresponding to the remainder: When m = 7896, the remainder of m / 34 is 8. Correspondingly, select the 8th character in the binary conversion key. It should be noted that since the remainder may be 0, counting can start from 0. Therefore, the 8th character in the binary conversion key "QGZVCXE012BDF345GHJ6K7L8M9NPSRUAWY" is "1". Additionally, after calculating the quotient of m / 34, m can be assigned the value of the quotient of m / 34, and steps S602 to S604 can be repeatedly executed until m < 34 - 1;
[0117] Step S605. Put the character into the character splicer: Put the character "1" into the character splicer. Similarly, the characters corresponding to the remainders selected from the binary conversion key each time steps S602 to S604 are repeated can be put into the character splicer.
[0118] For example, the quotient of m / 34 is 232. By step S602, it is determined that 232 satisfies m > 34 - 1, so m / 34 can be calculated according to step S603. When m = 232, the remainder of m / 34 is 28. By step S604, select the 28th character in the binary conversion key as "S", and put the character "S" into the character splicer. At this time, the value in the character splicer is "1S". Then, m can be assigned the value of the quotient of m / 34, so m = 6. By step S602, it is determined that 6 does not satisfy m > 34 - 1, so step S606 is executed;
[0119] Step S606. Select the character corresponding to the last operation result of m / 34 in the radix conversion key: As can be seen from Step S605, the last operation result is 6. Select the 6th character in the radix conversion key, which is "E", and put the character "E" into the character splicer. The value in the character splicer is updated to "1SE".
[0120] Step S607. Reverse the content in the character splicer: Reverse the content "1SE" in the character splicer to "ES1", that is, the string "ES1" is the second radix string obtained by converting the first radix string "7896" to radix 34 using the radix conversion key "QGZVCXE012BDF345GHJ6K7L8M9NPSRUAWY".
[0121] In the related art, the length of the ciphertext obtained by encrypting using the symmetric encryption algorithm is often long. It can be seen from this example that in the exemplary embodiment of the present disclosure, the length of the ciphertext is controlled by using a radix conversion key with a preset length. For example, the length of the encrypted ciphertext (such as "ES1") is made less than the length of the first radix string, so as to apply the data encryption method of the present disclosure to application scenarios with certain requirements for the length of the encrypted ciphertext.
[0122] In another exemplary embodiment, the radix conversion key randomly generated by the user can be a radix conversion key containing preset content, and the corresponding target attribute can be the key content. Exemplarily, the first radix string can be converted into a third radix string containing target content according to the radix conversion key containing preset content, and the third radix string is used as the second ciphertext.
[0123] Exemplarily, if the target content contained in the third radix string is any capital English letter and Arabic numeral except the capital English letters "I" and "O", correspondingly, the radix conversion key containing preset content can be a plurality of characters defined by the user except the capital English letters "I" and "O". For example, the radix conversion key not containing the capital English letters "I" and "O" can be "ASDFGHJKLQWERTYUPZXCVBNM1234567890". The process of converting the first radix string into the third radix string using the radix conversion key containing preset content is similar to Steps S601 to S608, and will not be elaborated here. It should be noted that a radix conversion key containing preset content and preset length can also be generated according to user needs to simultaneously control the content and length of the ciphertext, thereby improving the user experience.
[0124] In yet another exemplary embodiment, the length of the target plaintext may also be calculated, the length of the target plaintext may be converted into a quaternary string, and the quaternary string may be added to a target position in the binary string or the ternary string to obtain a third ciphertext. For example, for the target plaintext "A1+B2 / C3*", the length of the target plaintext is 9, and 9 may be converted into a quaternary string, such as being converted into the hexadecimal representation "C". Then, the character "C" may be added to a target position in the binary string or the ternary string to obtain a third ciphertext. For example, "C" may be added to the binary string "ZMHBLY5VA1CEF4". If the target position is after the third character of the binary string, the third ciphertext is "ZMHC BLY5VA1CEF4". The target position may be any position in the binary string or the ternary string, and the present disclosure does not make specific limitations thereto.
[0125] In this example, the ciphertext generated using the plaintext length is used to perform a shift process on the intermediate ciphertext, which improves the difficulty of deciphering the ciphertext. Moreover, since the entire encryption process undergoes multiple encryption steps such as bitmap conversion, radix conversion, character mapping, and shift processing, the difficulty of deciphering the ciphertext is relatively high. At this time, the ciphertext generated from the plaintext length is used as part of the final ciphertext, which facilitates determining the plaintext length using this part of the ciphertext during the decryption process, and at the same time, this part of the ciphertext can also be used for decryption operations such as bitmap inverse conversion. Therefore, using the ciphertext generated from the plaintext length as part of the final ciphertext can not only improve the difficulty of deciphering the ciphertext but also ensure the realization of the decryption process.
[0126] In a specific exemplary embodiment, the target plaintext is "A1+B2 / C3*". Referring to Figure 7 as shown, the target plaintext may be encrypted according to steps S701 to S706:
[0127] Step S701. Decompose "A1+B2 / C3*" into "ABC", "123", and "+ / *";
[0128] Step S702. Perform bitmap conversion on "123" to obtain the binary representation "010010010": Specifically, each character in "A1+B2 / C3*" is converted into the binary representation "010010010" according to the rule that "if the character is an Arabic numeral, it is marked as 1, and if the character is not an Arabic numeral, it is marked as 0". To prevent the first digit from being 0, a '1' is concatenated in front of the binary representation "010010010" to obtain a new binary representation "1010010010", and the binary representation "1010010010" is converted into the decimal representation 658;
[0129] Step S703. Perform bitmap conversion on "ABC" to obtain the binary string "100100100": Specifically, convert each character in "A1+B2 / C3*" into binary representation "100100100" according to the rule that "if the character is an English letter, it is marked as 1; if the character is not an English letter, it is marked as 0". To prevent the first digit from being 0, append a '1' in front of the binary representation "100100100" to obtain the new binary representation "1100100100", and convert the binary representation "1100100100" into decimal representation 804;
[0130] Step S704. Convert "ABC" to ASCII code "656667", and subtract the random number 38 from each bit of the ASCII code "656667" to obtain the ASCII code "272829";
[0131] Step S705. Map "+ / *" to obtain "789" through character mapping;
[0132] Step S706. Generate a three-digit random number with the first digit not being 0 by the encryption system, such as "456", and concatenate them in the following order: A. The random number "456"; B: The bitmap conversion string "804" of English letters; C: The bitmap conversion string "658" of Arabic numerals; D: The ASCII code integer "272829"; E: The string of Arabic numeral types in the target plaintext "123"; G: The special character mapping string "789" to obtain a large integer "456804658272829123789";
[0133] Step S707. Perform arbitrary base conversion on the large integer "456804658272829123789" according to the base conversion root key input by the user. For example, convert it from decimal to base 34, which is "ZMHBLY5VA1CEF4";
[0134] Step S708. Insert the ciphertext C obtained from the encrypted plaintext length into "ZMHBLY5VA1CEF4". For example, insert it after the third character in "ZMHBLY5VA1CEF4" to obtain the final ciphertext "ZMHCBLY5VA1CEF4".
[0135] In this exemplary embodiment, both the base conversion key and the number subtracted during ASCII code conversion are random. The entire encryption process undergoes multiple steps such as bitmap conversion, base conversion, and character mapping, and the ciphertext generated in the middle is shifted, making the finally generated ciphertext difficult to decipher.
[0136] Corresponding to Figure 7 the data encryption process shown, refer toFigure 8 As shown, the final generated ciphertext can be decrypted to obtain the target plaintext according to steps S801 to S809. Specifically:
[0137] Step S801. Decompose the ciphertext "ZMHCBLY5VA1CEF4" into ciphertext "ZMHBLY5VA1CEF4" and ciphertext "C";
[0138] Step S802. Perform an inverse base-64 conversion on the ciphertext "C" to obtain the character "9";
[0139] Step S803. According to the base conversion root key input by the user, perform an inverse base conversion on the ciphertext "ZMHBLY5VA1CEF4" to obtain the large integer "456804658272829123789";
[0140] Step S804. Remove the three-digit random number at the head of the large integer "456804658272829123789" to obtain the string "804658272829123789";
[0141] Step S805. Based on the character 9 obtained in step S802 and the string "804658272829123789" obtained in step S804, calculate two bitmaps and partial plaintexts, which are "804", "658", and "272829123789";
[0142] Step S806. Convert the bitmap "804" obtained in step S805 into binary representation to obtain the English letter bitmap "1100100100", and convert the bitmap "658" into binary representation to obtain the Arabic numeral bitmap "1010010010";
[0143] Step S807. Remove the leading "1" from the two bitmaps to obtain the English letter bitmap "100100100" and the Arabic numeral bitmap "010010010";
[0144] Step S808. Based on the English letter bitmap "100100100", the Arabic numeral bitmap "010010010", and the plaintext content "272829123789" obtained in step S805, calculate the plaintext content "272829", the plaintext content "123", and the plaintext content "789";
[0145] Step S809. For the plaintext content "272829", according to the "number subtracted in ASCII code conversion" provided by the user, perform inverse ASCII conversion bit by bit to obtain the string "ABC". For the plaintext content "789", according to the preset special character mapping table, perform inverse mapping operation bit by bit to obtain the string "+ / *". Calculate the final plaintext "A1+B2 / C3" based on the string "ABC", the string "+ / *", the English letter bitmap "100100100" obtained in step S807, the Arabic numeral bitmap "010010010", and the ciphertext content "123" obtained in step S808.
[0146] The data decryption process in this example is the inverse process of the data encryption process as shown in Figure 7 the figure. Correspondingly, since both the radix conversion key and the number subtracted during ASCII code conversion are random, the entire encryption process goes through multiple steps such as bitmap conversion, radix conversion, and character mapping, and the intermediate ciphertext is shifted, making it difficult to crack the ciphertext. Importantly, the radix conversion key is user-defined and generated, and it is not easy for other codebreakers to obtain the radix conversion key, so they cannot decrypt to obtain the target plaintext.
[0147] In a specific application scenario, the data encryption method in the exemplary embodiment of the present disclosure can be applied to a splicing screen anti-counterfeiting system. Exemplarily, the SN (Serial Number) codes of each splicing screen can be encrypted into ciphertext using the data encryption method of the present disclosure, and the ciphertext can be displayed to the inspection personnel in the form of a picture when leaving the factory for sale. The inspection personnel can scan the picture using a mobile terminal such as a smart phone. Specifically, the picture can be used as a parameter to call the interface of the splicing screen anti-counterfeiting system. After the background receives the picture parameter, it uses the OCR recognition program to recognize the ciphertext in the picture, and then decrypts the ciphertext to obtain the corresponding SN code. Finally, compare the decrypted SN code with the SN codes of each splicing screen stored in the database to determine whether the SN code is stored in the database. If it exists, the corresponding splicing screen is returned; if not, it means the product is a counterfeit and shoddy product.
[0148] Since the ciphertext is displayed on the screen and needs to be provided to the mobile phone camera for scanning in the form of a picture, the area for ciphertext display is small, and correspondingly, the length of the ciphertext needs to be controlled. At the same time, the ciphertext needs to be transmitted to the OCR recognition system in the form of a picture for recognition, so the content of the ciphertext needs to be easy to distinguish, and correspondingly, the content of the ciphertext needs to be controlled. For example, the ciphertext does not contain the Arabic numeral 1, the lowercase English letter l, and the uppercase English letter I at the same time, so as to avoid recognition errors. The present disclosure provides a highly customized data encryption method, which can set different encryption strategies for different application scenarios, so that the data encryption algorithm can be applied to more scenarios.
[0149] In the data encryption method provided by the exemplary embodiment of the present disclosure, a base conversion key randomly generated by a user is obtained; the target plaintext is encrypted according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key. The present disclosure can implement the control of the ciphertext in the symmetric encryption algorithm, so that the symmetric encryption algorithm can be flexibly applied to more scenarios.
[0150] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that these steps must be executed in that specific order, or that all the steps shown must be executed to achieve the desired result. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.
[0151] Furthermore, in the present exemplary embodiment, a data encryption device is also provided. Refer to Figure 9 As shown, the data encryption device 900 may include a key acquisition module 910 and a data encryption module 920, where:
[0152] The key acquisition module 910 is configured to obtain a base conversion key randomly generated by a user;
[0153] The data encryption module 920 is configured to encrypt the target plaintext according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
[0154] In an alternative embodiment, the data encryption device 900 further includes:
[0155] A plaintext decomposition module, configured to decompose the target plaintext into first strings of multiple types;
[0156] A first encoding module, configured to convert the first strings of corresponding types into second strings by using a preset encoding method;
[0157] A second encoding module, configured to convert the target plaintext into a third string according to a preset base conversion order;
[0158] A string combination module, configured to combine the first string, the second string, and the third string to obtain a first base string.
[0159] In an alternative embodiment, the base conversion key is a base conversion key of a preset length, and the target attribute includes the key length; the data encryption module 920 is configured to convert the first base string into a second base string of a target length according to the base conversion key of the preset length, and use the second base string as the first ciphertext.
[0160] In an alternative embodiment, the base conversion key is a base conversion key containing preset content, and the target attribute includes the key content; the data encryption module 920 is configured to convert the first base string into the third base string containing the target content according to the base conversion key containing the preset content, and use the third base string as the second ciphertext.
[0161] In an alternative embodiment, the data encryption module 920 further includes:
[0162] A third encoding module, configured to calculate the length of the target plaintext and convert the length of the target plaintext into a fourth base string;
[0163] A character shift module, configured to add the fourth base string to a target position in the second base string or the third base string to obtain a third ciphertext.
[0164] In an alternative embodiment, the type of the first string is a first type; the first encoding module includes:
[0165] A first encoding sub-module, configured to encode each character in the first string of the first type according to a preset first character mapping table to obtain a plurality of first encoding values;
[0166] A character conversion sub-module, configured to obtain a first random number generated by a user and calculate the second string according to each of the first encoding values and the first random number.
[0167] In an alternative embodiment, the type of the first string is a second type; the first encoding module is further configured to encode each character in the first string of the second type according to a preset second character mapping table to obtain a plurality of second encoding values; and splice the plurality of second encoding values to obtain the second string.
[0168] In an alternative embodiment, the second encoding module includes:
[0169] A second encoding sub-module, configured to traverse each character in the target plaintext, convert the characters in the target plaintext that conform to the target type into a third encoding value, and convert the other characters except the characters of the target type into a fourth encoding value;
[0170] An encoding value combination module, configured to form an intermediate base string from the third encoding value and the fourth encoding value based on the positions of the characters in the target plaintext;
[0171] A base conversion sub-module, configured to convert the intermediate base string into the third string in the target base.
[0172] In an alternative embodiment, the string combination module includes:
[0173] A random number acquisition sub-module, configured to acquire a second random number generated by the encryption system;
[0174] A string combination sub-module, configured to combine the first string of the target type, the multiple second strings obtained by converting the first strings of various types, the third string, and the second random number in a preset order to obtain the first base string.
[0175] The specific details of each module in the above data encryption device have been described in detail in the corresponding data encryption method, and thus will not be elaborated here.
[0176] The exemplary embodiments of the present disclosure further provide a computer-readable storage medium, on which a program product capable of implementing the above method of this specification is stored. In some possible embodiments, various aspects of the present disclosure may also be implemented in the form of a program product, which includes program code. When the program product runs on an electronic device, the program code is used to cause the electronic device to execute the steps according to various exemplary embodiments of the present disclosure described in the "Exemplary Method" section of this specification. The program product may be a portable compact disc read-only memory (CD-ROM) and includes program code, and may run on an electronic device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
[0177] The program product may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0178] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which the readable program code is carried. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable signal medium may also be any readable medium other than a readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
[0179] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0180] The program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0181] Exemplary embodiments of the present disclosure also provide an electronic device capable of implementing the above method. The following refers to Figure 10 to describe the electronic device 1000 according to such an exemplary embodiment of the present disclosure. Figure 10 The illustrated electronic device 1000 is merely an example and should not impose any limitation on the functions and scope of use of the embodiments of the present disclosure.
[0182] As shown Figure 10 in FIG. 1, the electronic device 1000 may be embodied in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040. Among them, the display unit 1040 may be a scanning display device or other electronic devices including a display screen, including but not limited to desktop computers, portable computers, smart phones, tablet computers, etc.
[0183] The storage unit 1020 stores program code, and the program code can be executed by the processing unit 1010, so that the processing unit 1010 executes the steps according to various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of this specification. For example, the processing unit 1010 may execute Figures 2 to 8 any one or more of the method steps in
[0184] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 1021 and / or a cache storage unit 1022, and may further include a read-only storage unit (ROM) 1023.
[0185] The storage unit 1020 may further include a program / utilities 1024 having a set (at least one) of program modules 1025. Such program modules 1025 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment.
[0186] The bus 1030 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus structures.
[0187] The electronic device 1000 may also communicate with one or more external devices 1100 (such as a keyboard, a pointing device, a Bluetooth device, etc.), and may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication may be carried out through an input / output (I / O) interface 1050. And, the electronic device 1000 may also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 1060. As shown Figure 10As shown, network adapter 1060 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that although Figure 10 not shown in Figure 10 , other hardware and / or software modules may be used in conjunction with electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0188] In some embodiments, the data encryption method described in this disclosure may be executed by processing unit 1010 of the electronic device. Exemplarily, a user-randomly generated radix conversion key and a first random number, etc. may be input through input interface 1050. For example, a user-randomly generated radix conversion key and a first random number, etc. are input through the user interface of the electronic device. Correspondingly, the encrypted ciphertext may be output to external device 1100 through output interface 1050 for the user to view.
[0189] From the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solution according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which may be a CD-ROM, USB flash drive, mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which may be a personal computer, server, terminal device, or network device, etc.) to execute the method according to the exemplary embodiments of this disclosure.
[0190] In addition, the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of this disclosure, rather than for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the time sequence of these processes. Additionally, it is also easy to understand that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0191] It should be noted that although several modules or units of the devices for action execution are mentioned in the above detailed description, such a division is not mandatory. In fact, according to the embodiments of this disclosure, the features and functions of two or more of the above-described modules or units may be embodied in one module or unit. Conversely, the features and functions of one module or unit described above may be further divided and embodied by multiple modules or units.
[0192] It should be understood that this disclosure is not limited to the exact structures that have been described and shown in the drawings above, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is only limited by the appended claims.
Claims
1. A data encryption method, characterized in that, it includes: Obtain a base conversion key randomly generated by the user; Decompose the target plaintext into first strings of multiple types; Convert the first strings of corresponding types into second strings by using a preset encoding method; Convert the target plaintext into a third string according to a preset base conversion order; Combine the first string, the second string and the third string to obtain a first base string; Encrypt the first base string according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
2. The data encryption method according to claim 1, characterized in that, the base conversion key is a base conversion key of a preset length, and the target attribute includes the key length; The encrypting the first base string according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key includes: Convert the first base string into a second base string of a target length according to the base conversion key of the preset length, and use the second base string as the first ciphertext.
3. The data encryption method according to claim 1, characterized in that, the base conversion key is a base conversion key containing preset content, and the target attribute includes the key content; The encrypting the first base string according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key includes: Convert the first base string into a third base string containing target content according to the base conversion key containing preset content, and use the third base string as the second ciphertext.
4. The data encryption method according to claim 2, characterized in that, the method further includes: Calculate the length of the target plaintext, and convert the length of the target plaintext into a fourth base string; Add the fourth base string to a target position in the second base string to obtain a third ciphertext.
5. The data encryption method according to claim 3, characterized in that, the method further includes: Calculate the length of the target plaintext, and convert the length of the target plaintext into a fourth base string; Add the fourth base string to a target position in the third base string to obtain a third ciphertext.
6. The data encryption method according to claim 1, characterized in that, the type of the first string is the first type; the converting the first string of corresponding type into a second string by using a preset encoding method includes: Encode each character in the first string of the first type according to a preset first character mapping table to obtain a plurality of first encoded values; Obtain a first random number generated by the user, and calculate the second string according to each of the first encoded values and the first random number.
7. The data encryption method according to claim 1, characterized in that, the type of the first string is the second type; the converting the first string of corresponding type into a second string by using a preset encoding method includes: Encode each character in the first string of the second type according to a preset second character mapping table to obtain a plurality of second encoding values; Concatenate the plurality of second encoding values to obtain the second string.
8. The data encryption method according to claim 1, characterized in that, The converting the target plaintext into a third string according to a preset base conversion order includes: Traverse each character in the target plaintext, convert the characters that conform to the target type in the target plaintext into third encoding values, and convert the other characters except the characters of the target type into fourth encoding values; Based on the positions of the characters in the target plaintext, form an intermediate base string from the third encoding values and the fourth encoding values; Convert the intermediate base string into the third string in the target base.
9. The data encryption method according to claim 1, characterized in that, The combining the first string, the second string and the third string to obtain a first base string includes: Obtain a second random number generated by the encryption system; Combine the first string of the target type, the plurality of second strings obtained by converting the first strings of various types, the third string and the second random number in a preset order to obtain the first base string.
10. A data encryption device, characterized in that, comprising: A key acquisition module for acquiring a base conversion key randomly generated by a user; A data encryption module, including a plaintext decomposition module, a first encoding module, a second encoding module and a string combination module; The plaintext decomposition module is used for decomposing the target plaintext into first strings of various types; the first encoding module is used for converting the first strings of corresponding types into second strings by using a preset encoding method; the second encoding module is used for converting the target plaintext into a third string according to a preset base conversion order; the string combination module is used for combining the first string, the second string and the third string to obtain a first base string; The data encryption module is used for encrypting the first base string according to the base conversion key to obtain a ciphertext corresponding to the target attribute of the base conversion key.
11. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by a processing unit, the method according to any one of claims 1-9 is implemented.
12. An electronic device, characterized in that, comprising: A processing unit; A display unit; and A storage unit for storing executable instructions of the processing unit; Wherein, the processing unit is configured to execute the method according to any one of claims 1-9 by executing the executable instructions; the display unit is used for displaying the ciphertext generated after executing the method according to any one of claims 1-9.
Citation Information
Patent Citations
Particle accelerator to generate random numbers for cryptographic applications
US20200403790A1