Encryption method, device, equipment and storage medium based on magic cube
By determining different encryption paths in the encryption cube to encrypt the target data, the problem of low security of existing encryption algorithms is solved, and higher encryption security and complexity are achieved.
Patent Information
- Application Number
- CN202210537245.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-05-16
AI Technical Summary
The security of existing encryption algorithms has been reduced due to the development of quantum computing technology, making it difficult to effectively resist the cracking of encryption keys.
The encryption method based on the Rubik's Cube is adopted to enhance the complexity of the encryption process and the complexity of the encryption key by building an encryption cube, determining the encryption path, and preprocessing and encrypting the target data, thereby enhancing encryption security.
The different starting encryption nodes and terminating encryption nodes determine different encryption paths in the encryption cube, which increases the diversity and complexity of the encryption key, improves encryption security, and reduces the difficulty of cracking ciphertexts.
Smart Images

Figure CN115001690B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to an encryption method, device, equipment and storage medium based on a magic cube. Background Art
[0002] The current encryption algorithm is mainly RSA encryption algorithm, etc. For example, RSA encryption algorithm obtains encryption key through large prime numbers and power operation, and then uses the encryption key to encrypt plain text. However, with the development of quantum computing technology, the efficiency of cracking encryption keys obtained through large prime numbers and power operation has been improved, which has led to a decrease in the security of encryption algorithms. Summary of the invention
[0003] The main purpose of this application is to provide an encryption method, device, equipment and storage medium based on the magic cube, aiming to solve the technical problem of low security of existing encryption algorithms.
[0004] To achieve the above purpose, the present application provides an encryption method based on magic cube, comprising the following steps:
[0005] Build a crypto cube;
[0006] Determining an encryption path in the encryption cube based on a preset start encryption node and an end encryption node;
[0007] Preprocessing the target data to obtain preprocessed data;
[0008] Based on the encryption path, characters in the preprocessed data are encrypted one by one to obtain the ciphertext of the target data.
[0009] Optionally, the step of constructing an encrypted Rubik's Cube includes:
[0010] Construct the basic Rubik's Cube;
[0011] According to the turntable screening function, determining the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption turntable;
[0012] Determine the arrangement order of the characters of the middle ring of the encryption turntable according to the middle ring function of the turntable;
[0013] Based on the mapping relationship between the first ring, the second ring and the middle ring and the nodes of the basic Rubik's Cube, the encryption turntable of the nodes of the basic Rubik's Cube is determined to obtain an encrypted Rubik's Cube, wherein the characters of the first ring of the encryption turntable are mapped with the characters of the second ring of the encryption turntable to generate the encryption mapping relationship corresponding to the encryption turntable, and the characters of the middle ring of the encryption turntable are mapped with the characters of the first ring / second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable.
[0014] Optionally, the step of encrypting characters in the preprocessed data one by one based on the encryption path to obtain the ciphertext of the target data includes:
[0015] Based on the encryption mapping relationship corresponding to the encryption disk of each encryption node in the encryption path, and according to the order of each encryption node in the encryption path, the character is mapped and encrypted step by step to obtain the ciphertext of the character;
[0016] Updating the encryption mapping relationship corresponding to the encryption turntable of each encryption node;
[0017] Updating the encryption nodes on the encryption path;
[0018] Determining whether there are unencrypted characters in the preprocessed data;
[0019] If there is no unencrypted character in the preprocessed data, sorting the ciphertext of the character according to the order of the character in the preprocessed data to obtain the ciphertext of the target data;
[0020] If there are unencrypted characters in the preprocessed data, the encryption mapping relationship corresponding to the encryption dial based on each encryption node in the encryption path is returned, and the characters are mapped and encrypted step by step according to the order of each encryption node in the encryption path to obtain the ciphertext of the characters.
[0021] Optionally, after the step of mapping and encrypting the characters step by step based on the encryption mapping relationship corresponding to the encryption disk of each encryption node in the encryption path and according to the order of each encryption node in the encryption path to obtain the ciphertext of the characters, the method further includes:
[0022] Based on the interference mapping relationship corresponding to the encryption dial of the terminating encryption node in the encryption path, the interference ciphertext corresponding to the character is determined, and the interference ciphertext is combined with the ciphertext of the character.
[0023] Optionally, the step of updating the encryption mapping relationship corresponding to the encryption turntable of each encryption node includes:
[0024] Determine the rotation starting position of the encryption turntable of each encryption node according to the turntable initialization function;
[0025] Determining the rotation characteristic data of the encryption turntable of each encryption node according to the turntable rotation function;
[0026] Based on the rotation starting position and the rotation characteristic data, the encryption mapping relationship corresponding to the encryption turntable of each encryption node is updated.
[0027] Optionally, the step of updating the encryption nodes on the encryption path includes:
[0028] When the order of the encryption node where the encryption turntable is located in the encryption path is an odd number, the encryption cube is rotated according to the first preset rotation rule;
[0029] When the encryption node where the encryption turntable is located is ranked in an even number in the encryption path, the encryption Rubik's Cube is rotated according to a second preset rotation rule.
[0030] Optionally, the step of preprocessing the target data to obtain preprocessed data includes:
[0031] The target data is preprocessed to obtain preprocessed data, wherein the preprocessed data is represented by 64 characters corresponding to the Base64 encoding.
[0032] In addition, to achieve the above purpose, the present application also provides an encryption device based on the magic cube, including:
[0033] Building blocks for building crypto cubes;
[0034] A path determination module, used to determine an encryption path in the encryption cube based on a preset start encryption node and an end encryption node;
[0035] A data preprocessing module is used to preprocess the target data to obtain preprocessed data;
[0036] The encryption module is used to encrypt the characters in the preprocessed data one by one based on the encryption path to obtain the ciphertext of the target data.
[0037] In addition, to achieve the above-mentioned purpose, the present application also provides a Rubik's Cube-based encryption device, which includes: a memory, a processor, and a Rubik's Cube-based encryption program stored on the memory and executable on the processor, and the Rubik's Cube-based encryption program is configured to implement the steps of the Rubik's Cube-based encryption method as described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, on which a magic cube-based encryption program is stored, and when the magic cube-based encryption program is executed by a processor, the steps of the magic cube-based encryption method described above are implemented.
[0039] The present application discloses an encryption method, device, equipment and storage medium based on a magic cube. Compared with the prior art, in which the encryption algorithm has low security, the present embodiment constructs an encryption magic cube; based on a preset starting encryption node and an ending encryption node, an encryption path is determined in the encryption magic cube; the target data is preprocessed to obtain preprocessed data; based on the encryption path, the characters in the preprocessed data are encrypted one by one to obtain the ciphertext of the target data. That is to say, in the present application, different encryption paths can be obtained in the encryption magic cube based on different starting encryption nodes and ending encryption nodes, and the characters in the preprocessed data are encrypted one by one according to the encryption path, which increases the complexity of the encryption process and the complexity of the encryption key, thereby increasing the encryption security. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 It is a structural diagram of a magic cube-based encryption device in a hardware operating environment involved in an embodiment of the present application;
[0043] Figure 2 This is a flow chart of the first embodiment of the encryption method based on the magic cube of the present application;
[0044] Figure 3 A schematic diagram of the rotation form of the encrypted Rubik's Cube for this application;
[0045] Figure 4 This is a functional module diagram of the first embodiment of the encryption device based on the magic cube of the present application.
[0046] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a Rubik's Cube-based encryption device in the hardware operating environment involved in the embodiment of the present application.
[0049] like Figure 1 As shown, the magic cube-based encryption device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0050] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the magic cube-based encryption device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0051] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module and a magic cube-based encryption program.
[0052] exist Figure 1 In the Rubik's Cube-based encryption device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the Rubik's Cube-based encryption device of the present application can be set in the Rubik's Cube-based encryption device, and the Rubik's Cube-based encryption device calls the Rubik's Cube-based encryption program stored in the memory 1005 through the processor 1001, and executes the Rubik's Cube-based encryption method provided in the embodiment of the present application.
[0053] The present application embodiment provides an encryption method based on the magic cube, referring to Figure 2 , Figure 2 This is a flow chart of the first embodiment of the encryption method based on the magic cube of the present application.
[0054] In this embodiment, the magic cube-based encryption method includes:
[0055] Step S10, constructing an encrypted Rubik's Cube;
[0056] Step S20, determining an encryption path in the encryption cube based on a preset start encryption node and an end encryption node;
[0057] Step S30, preprocessing the target data to obtain preprocessed data;
[0058] Step S40: Based on the encryption path, encrypt the characters in the preprocessed data one by one to obtain the ciphertext of the target data.
[0059] Compared with the prior art, in which the encryption algorithm has low security, this embodiment constructs an encryption cube; based on a preset starting encryption node and an ending encryption node, an encryption path is determined in the encryption cube; the target data is preprocessed to obtain preprocessed data; based on the encryption path, the characters in the preprocessed data are encrypted one by one to obtain the ciphertext of the target data. That is to say, in this embodiment, different encryption paths can be obtained in the encryption cube based on different starting encryption nodes and ending encryption nodes, and the characters in the preprocessed data are encrypted one by one according to the encryption path, which increases the complexity of the encryption process and the complexity of the encryption key, thereby improving the encryption security.
[0060] The specific steps are as follows:
[0061] Step S10, constructing an encrypted Rubik's Cube.
[0062] It should be noted that, in this embodiment, there are multiple encryption nodes on the encryption cube, and each encryption node includes an encryption turntable.
[0063] Specifically, building an encryption cube includes:
[0064] Step S11, constructing a basic Rubik's Cube.
[0065] In this embodiment, the basic Rubik's Cube can be represented by G(V, E), wherein V represents the set of all nodes in the basic Rubik's Cube, and E represents the set of edges connecting the nodes in the basic Rubik's Cube. In order to simplify the construction process of the basic Rubik's Cube, a Rubik's Cube of three-order, four-order, five-order, six-order, triangle, diamond, and spherical Rubik's cube can be selected as the basic Rubik's Cube.
[0066] Taking the Rubik's Cube in three dimensions as an example, the Rubik's Cube in three dimensions consists of 6 center blocks, 12 edge blocks and 8 corner blocks. The edges and nodes on the surfaces of the center blocks, edge blocks and corner blocks are the nodes and edges in the basic Rubik's Cube. The Rubik's Cube in three dimensions has a total of 56 nodes and 72 edges.
[0067] Step S12: Determine the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption turntable according to the turntable screening function.
[0068] In this embodiment, the turntable screening function S(para, EB) is used to determine the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption turntable from the password data set according to the screening parameter para and the screening rule. Among them, one screening parameter can correspond to one screening rule or multiple screening rules.
[0069] In this embodiment, the screening parameter para includes the code or password corresponding to each node in the basic Rubik's Cube, wherein the password is updated regularly.
[0070] In this embodiment, the first ring and the second ring of the encryption disk are equally divided into 64 parts, that is, the first ring and the second ring of the encryption disk each contain 64 characters. By arranging and combining the 64 characters corresponding to the Base64 code (based on 64 printable characters to represent binary data), 64! password strings can be generated, and each password string includes 64 characters corresponding to the Base64 code. The password string in the password data set is a part of the 64! password strings, and the password strings in the password data set have their corresponding numbers, and the password strings in the password data set can be updated regularly.
[0071] That is to say, in this embodiment, according to the wheel screening function, there are two different ways to determine the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption wheel.
[0072] Method 1: When one screening parameter corresponds to one screening rule, the arrangement order of the characters of the first ring of the encryption disk is determined from the password data set according to the first screening parameter and the corresponding screening rule, and the arrangement order of the characters of the second ring of the encryption disk is determined from the password data set according to the second screening parameter and the corresponding screening rule, wherein the first screening parameter and the second screening parameter are a type of the screening parameter para, and the first screening parameter and the second screening parameter are different.
[0073] For example, the first screening parameter is the code corresponding to each node in the basic Rubik's Cube, and the corresponding screening rule is to round the first screening parameter to the power of e. Then, according to the first screening parameter and the corresponding screening rule, the arrangement order of the characters of the first ring of the encryption turntable is determined from the password data set, including:
[0074] The code corresponding to the node is converted so that the representation form of the code corresponding to the node is in digital form, the e-th power of the code corresponding to the node is rounded, and the data obtained after rounding is regarded as the code corresponding to the password string. The corresponding password string is extracted from the password data set according to the data obtained after rounding. The password string is the arrangement order of the characters in the first ring of the encryption turntable.
[0075] The second screening parameter is a password, then according to the second screening parameter and the corresponding screening rule, determining the arrangement order of the characters of the second ring of the encryption turntable from the password data set includes:
[0076] The password is converted into a digital password, and the 1 / 2 power of the digital password is rounded. The data obtained after rounding is regarded as the code corresponding to the password string. The corresponding password string is extracted from the password data set according to the data obtained after rounding. The password string is used as the arrangement sequence of the characters of the second ring of the first encryption turntable. After every t password strings, the t+1th password string is selected as the arrangement sequence of the characters of the second ring of the encryption turntable, until the arrangement sequence of the characters of the second ring of N encryption turntables is determined, and N is the number of nodes in the basic Rubik's cube.
[0077] It should be noted that the filtering rules corresponding to the filtering parameters can be set according to actual application conditions and are not limited to the filtering rules illustrated in the above examples. More filtering rules will not be described in detail here.
[0078] Method 2: When one screening parameter corresponds to multiple screening rules, the arrangement order of the characters of the first ring of the encryption wheel is determined from the password data set according to the first screening rule corresponding to the screening parameter, and the arrangement order of the characters of the second ring of the encryption wheel is determined from the password data set according to the second screening rule corresponding to the screening parameter.
[0079] For example, the screening parameter is the code corresponding to each node in the basic Rubik's Cube, and the corresponding first screening rule is to round the first screening parameter to the power of e. Then, according to the first screening rule corresponding to the screening parameter, the arrangement order of the characters of the first ring of the encryption turntable is determined from the password data set, including:
[0080] The e-th power of the code corresponding to the node is rounded, and the data obtained after the rounding is regarded as the code corresponding to the password string. The corresponding password string is extracted from the password data set according to the data obtained after the rounding, and the password string is the arrangement order of the characters of the first ring of the encryption turntable; the corresponding second screening rule is to round the 1 / 2 power of the second screening parameter, then according to the second screening rule corresponding to the screening parameter, the arrangement order of the characters of the second ring of the encryption turntable is determined from the password data set, including: rounding the 1 / 2 power of the code corresponding to the node, and the data obtained after the rounding is regarded as the code corresponding to the password string, and the corresponding password string is extracted from the password data set according to the data obtained after the rounding, and the password string is the arrangement order of the characters of the second ring of the encryption turntable.
[0081] It should be noted that the multiple filtering rules corresponding to the filtering parameters can be set according to actual application conditions and are not limited to the filtering rules illustrated in the above examples. More filtering rules will not be described in detail here.
[0082] Step S13: determining the arrangement order of the characters in the middle ring of the encryption turntable according to the middle ring function of the turntable.
[0083] In this embodiment, the turntable middle ring function A(para1, n) is used to determine the arrangement order of the characters in the middle ring of the encryption turntable from the row key data set according to the middle screening parameter para1 and the character length n.
[0084] In this embodiment, the process of obtaining the row key data set is as follows:
[0085] Perform Base64 encoding on each line of text in a plain text information data set containing multiple lines of text to obtain the encoding information corresponding to each line of text;
[0086] A character string whose length is greater than a preset length value is intercepted from the encoded information corresponding to each line of text, and the character string is rearranged and combined based on the parity character interchange rule to obtain the row key corresponding to each line of text to form a row key data set, wherein the length of the row key corresponding to each line of text is different.
[0087] It should be noted that, in this embodiment, the preset length value is preferably 2048.
[0088] Specifically, when the intermediate screening parameter is the code corresponding to each node in the basic Rubik's Cube, the arrangement order of the characters in the middle ring of the encryption turntable is determined according to the middle ring function of the turntable, including:
[0089] The code corresponding to the node is converted so that the representation form of the code corresponding to the node is in digital form, the a-th power of the code corresponding to the node is rounded, and the data obtained after rounding is regarded as the code corresponding to the row key, and the corresponding row key is extracted from the row key data set according to the rounded data, and a character string of length kn is intercepted from the extracted row key as the arrangement order of the characters of the middle ring of the encryption turntable, wherein k is the number of characters in the middle ring, and n is the character length of the middle ring.
[0090] Specifically, when the intermediate screening parameter is a password, the arrangement order of the characters of the middle ring of the encryption turntable is determined according to the turntable middle ring function, including:
[0091] The password is converted into a digital password, and the a-th power of the digital password is rounded, and the rounded data is regarded as the code corresponding to the row key. The corresponding row key is extracted from the row key data set according to the rounded data, and the extracted row key is used as the arrangement sequence of the characters of the second ring of the first encryption turntable. After each interval of T password strings, the T+1th password string is selected as the arrangement sequence of the characters of the second ring of the encryption turntable, until the arrangement sequence of the characters of the second ring of N encryption turntables is determined, and N is the number of nodes in the basic Rubik's cube.
[0092] In this embodiment, the first ring and the second ring of the encryption disk are equally divided into 64 parts, so the middle ring of the encryption disk is also equally divided into 64 parts, that is, k = 64. The character length n of the middle ring is a positive integer greater than 2 and can be set according to actual application requirements.
[0093] Step S14, based on the mapping relationship between the first ring, the second ring and the middle ring and the nodes of the basic Rubik's Cube, determine the encryption turntable of the nodes of the basic Rubik's Cube to obtain an encrypted Rubik's Cube, wherein the characters of the first ring of the encryption turntable are mapped with the characters of the second ring of the encryption turntable to generate the encryption mapping relationship corresponding to the encryption turntable, and the characters of the middle ring of the encryption turntable are mapped with the characters of the first ring / second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable.
[0094] In this embodiment, the order of the characters on the first ring and the second ring of the encryption turntable is a combination of 64 characters corresponding to the Base64 encoding, that is, the characters on the first ring of the encryption turntable are mapped with the characters on the second ring of the encryption turntable to generate the encryption mapping relationship corresponding to the encryption turntable, which can be as high as 64!, thereby increasing the complexity of the encryption key. The characters on the middle ring of the encryption turntable are mapped with the characters on the first ring / second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable, which can realize asymmetric encryption of characters and improve the interference of ciphertext.
[0095] In this embodiment, there are mapping relationships between the first ring of the encryption turntable, the second ring of the encryption turntable, and the middle ring of the encryption turntable and the nodes of the basic Rubik's Cube.
[0096] If the screening parameter for determining the order of arrangement of characters in the first ring of the encryption turntable is the code corresponding to each node of the basic Rubik's Cube, then the node corresponding to the first ring of the encryption turntable in the basic Rubik's Cube is the node corresponding to the screening parameter. For example, the order of arrangement of characters in the first ring of the encryption turntable is determined based on the code corresponding to node S11 in the basic Rubik's Cube, then the first ring of the encryption turntable is set on node S11 in the basic Rubik's Cube. Similarly, the screening parameter for determining the order of arrangement of characters in the second ring of the encryption turntable is also the code corresponding to each node of the basic Rubik's Cube, then the node corresponding to the second ring of the encryption turntable is the node corresponding to the screening parameter. Similarly, the intermediate screening parameter for determining the order of arrangement of characters in the middle ring of the encryption turntable is also the code corresponding to each node of the basic Rubik's Cube, then the node corresponding to the middle ring of the encryption turntable is the node corresponding to the intermediate screening parameter.
[0097] If the screening parameter for determining the arrangement order of the characters of the first ring of the encryption turntable is a password, then the mapping relationship between the first ring of the encryption turntable and the nodes of the basic Rubik's Cube is:
[0098] The codes corresponding to the nodes of the basic Rubik's Cube are converted into digital codes, and the sum of the numbers in the digital codes is calculated. According to the sum of the numbers, the digital codes are sorted in order of size, that is, the nodes of the basic Rubik's Cube are sorted; the codes of the row keys corresponding to the arrangement order of the characters of the first ring of the N encryption turntables are used as the codes corresponding to the first ring of the N encryption turntables, the codes corresponding to the first ring of the N encryption turntables are converted into digital codes, and the sum of the numbers in the digital codes is calculated. According to the sum of the numbers, the digital codes are sorted in order of size, that is, the first ring of the N encryption turntables is sorted; the sorted nodes of the basic Rubik's Cube are made to correspond one by one to the first rings of the sorted N encryption turntables.
[0099] Similarly, if the screening parameter that determines the arrangement order of the characters of the first ring of the encryption wheel is also a password, then the mapping relationship between the second ring of the encryption wheel and the nodes of the basic Rubik's Cube is the same as the mapping relationship between the first ring of the encryption wheel and the nodes of the basic Rubik's Cube; if the intermediate screening parameter that determines the arrangement order of the characters of the middle ring of the encryption wheel is also a password, then the mapping relationship between the middle ring of the encryption wheel and the nodes of the basic Rubik's Cube is the same as the mapping relationship between the first ring of the encryption wheel and the nodes of the basic Rubik's Cube.
[0100] It should be noted that the mapping relationship between the first ring of the encryption turntable and the nodes of the basic Rubik's Cube, the mapping relationship between the second ring of the encryption turntable and the nodes of the basic Rubik's Cube, and the mapping relationship between the middle ring of the encryption turntable and the nodes of the basic Rubik's Cube, these three mapping relationships can be the same or different, and can be set according to actual application requirements.
[0101] Step S20: determining an encryption path in the encryption cube based on a preset start encryption node and an end encryption node.
[0102] In this embodiment, the preset start encryption node and the end encryption node are the encryption nodes in the encryption cube. The start encryption node and the end encryption node can be set according to the actual application requirements, or the corresponding start encryption node and the end encryption node can be matched according to the data size of the target data. That is, in this embodiment, there is a mapping table of the preset target data size and the start encryption node and the end encryption node, in which a group of start encryption nodes and the end encryption node correspond to a segment of the target data size.
[0103] Specifically, based on a preset starting encryption node and an ending encryption node, an encryption path is determined in the encryption cube, including:
[0104] Based on the preset starting encryption node and ending encryption node, an encryption path is determined in the encryption cube according to the shortest path principle;
[0105] Alternatively, based on a preset starting encryption node and an ending encryption node, an encryption path is determined in the encryption cube according to the longest path principle.
[0106] It should be noted that, given two points, determining the path between the two points according to the shortest path principle / longest path principle is a prior art, and thus will not be described in detail in this embodiment.
[0107] In this embodiment, different encryption paths can be obtained in the encryption cube based on different starting encryption nodes and ending encryption nodes. Different encryption paths correspond to different encryption dials, that is, to different encryption keys, which increases the diversity of encryption keys and further improves encryption security.
[0108] Step S30: pre-process the target data to obtain pre-processed data.
[0109] Specifically, the target data is preprocessed to obtain preprocessed data, wherein the preprocessed data is represented by 64 characters corresponding to the Base64 encoding.
[0110] In this embodiment, there are two ways to preprocess the target data to obtain preprocessed data represented by 64 characters corresponding to the Base64 encoding.
[0111] Method 1: Base64 encode the target data to obtain preprocessed data.
[0112] Method 2: Encrypt the target data once to obtain an encrypted ciphertext, and perform Base64 encoding on the encrypted ciphertext to obtain preprocessed data.
[0113] Among them, the encryption algorithm used to encrypt the target data once in method 2 can be an RSA encryption algorithm, an ECC encryption algorithm, etc.
[0114] Among them, the Base64 encoding method used in Method 1 and Method 2 of this embodiment is different from the general Base64 method. The difference between the two is that the Base64 encoding method used in this embodiment can set the order of 64 characters in the conversion table according to actual application requirements (personalization), that is, set the mapping correspondence between the 64 characters in the conversion table and the numbers 0 to 63 according to actual application requirements, thereby enhancing the security of this embodiment.
[0115] Step S40: Based on the encryption path, encrypt the characters in the preprocessed data one by one to obtain the ciphertext of the target data.
[0116] Specifically, based on the encryption path, characters in the preprocessed data are encrypted one by one to obtain the ciphertext of the target data, including:
[0117] Step S41, based on the encryption mapping relationship corresponding to the encryption dial of each encryption node in the encryption path, and according to the order of each encryption node in the encryption path, the characters are mapped and encrypted step by step to obtain the ciphertext of the characters.
[0118] For example, there are five encryption nodes in the encryption path, namely the first encryption node, the second encryption node, the third encryption node, the fourth encryption node and the fifth encryption node. A character in the preprocessed data is extracted, and the first mapping character corresponding to the character is obtained according to the encryption mapping relationship corresponding to the encryption disk of the first encryption node, and then the second mapping character corresponding to the first mapping character is obtained according to the encryption mapping relationship corresponding to the encryption disk of the second encryption node, and then the third mapping character corresponding to the second mapping character is obtained according to the encryption mapping relationship corresponding to the encryption disk of the third encryption node, and then the fourth mapping character corresponding to the third mapping character is obtained according to the encryption mapping relationship corresponding to the encryption disk of the fourth encryption node, and finally the fifth mapping character corresponding to the fourth mapping character is obtained according to the encryption mapping relationship corresponding to the encryption disk of the fifth encryption node, and the fifth mapping character is the ciphertext of the character.
[0119] Step S42: determine the interference ciphertext corresponding to the character based on the interference mapping relationship corresponding to the encryption dial of the terminating encryption node in the encryption path, and combine the interference ciphertext into the ciphertext of the character.
[0120] For example, there are five encryption nodes in the encryption path, namely the first encryption node, the second encryption node, the third encryption node, the fourth encryption node and the fifth encryption node, and the fifth encryption node is the termination encryption node. While obtaining the fifth mapping character corresponding to the fourth mapping character according to the encryption mapping relationship corresponding to the encryption disk of the fifth encryption node, the interference character corresponding to the fourth mapping character is obtained according to the interference mapping relationship corresponding to the encryption disk of the fifth encryption node, and the interference character is the interference ciphertext corresponding to the character.
[0121] In this embodiment, combining the interference ciphertext with the ciphertext of the character may be performed by adding the interference ciphertext to the end of the ciphertext of the character, or by adding the interference ciphertext to the beginning of the ciphertext of the character.
[0122] In this embodiment, interference ciphertext is added to the ciphertext of the characters, thereby further improving the security of the ciphertext.
[0123] Step S43: updating the encryption mapping relationship corresponding to the encryption disk of each encryption node.
[0124] Specifically, updating the encryption mapping relationship corresponding to the encryption turntable of each encryption node includes:
[0125] Step S431: Determine the rotation start position of the encryption turntable of each encryption node according to the turntable initialization function.
[0126] In this embodiment, according to the turntable initialization function, the specific process of determining the rotation starting position of the encryption turntable of each encryption node is as follows:
[0127] The code corresponding to the encryption node where the encryption turntable is located in the encryption cube is converted to obtain the digital code corresponding to the encryption node where the encryption turntable is located in the encryption cube, the a-th power of the digital code is rounded, and the rounded data is regarded as the code corresponding to the row key, and the corresponding row key is extracted from the row key data set according to the rounded data, and the number of each character in the extracted row key is counted, and the character with the largest number is selected as the character corresponding to the starting position of the rotation of the encryption turntable.
[0128] Step S432: Determine the rotation characteristic data of the encryption turntable of each encryption node according to the turntable rotation function.
[0129] In this embodiment, the rotation characteristic data of the encrypted turntable includes the rotation direction and the number of rotation grids.
[0130] When the characters of the middle ring of the encryption turntable are mapped to the characters of the first ring of the encryption turntable to generate an interference mapping relationship corresponding to the encryption turntable, the rotation feature data of the encryption turntable of each encryption node is determined according to the turntable rotation function, including:
[0131] When the encryption node where the encryption turntable is located is ranked odd in the encryption path, the first ring of the encryption turntable rotates clockwise, and the middle ring of the encryption turntable rotates counterclockwise; when the encryption node where the encryption turntable is located is ranked even in the encryption path, the first ring of the encryption turntable rotates counterclockwise, and the middle ring of the encryption turntable rotates clockwise;
[0132] The order of the encryption nodes where the encryption turntable is located in the encryption path is used as the number of rotation grids of the first ring and the middle ring of the encryption turntable.
[0133] When the characters of the middle ring of the encryption turntable are mapped to the characters of the second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable, the rotation feature data of the encryption turntable of each encryption node is determined according to the turntable rotation function, including:
[0134] When the encryption node where the encryption turntable is located is ranked odd in the encryption path, the second ring of the encryption turntable rotates clockwise, and the middle ring of the encryption turntable rotates counterclockwise; when the encryption node where the encryption turntable is located is ranked even in the encryption path, the second ring of the encryption turntable rotates counterclockwise, and the middle ring of the encryption turntable rotates clockwise;
[0135] The order of the encryption nodes where the encryption turntable is located in the encryption path is used as the number of rotation grids of the second ring and the middle ring of the encryption turntable.
[0136] Step S433: based on the rotation starting position and the rotation characteristic data, the encryption mapping relationship corresponding to the encryption turntable of each encryption node is updated.
[0137] For example, the first character of the row key is A, the character of the middle ring of the encryption turntable is mapped to the character of the second ring of the encryption turntable to generate an interference mapping relationship corresponding to the encryption turntable, and the encryption node where the encryption turntable is located is ranked 1 in the encryption path, then the position of the character A in the second ring of the encryption turntable is used as the rotation starting position, the second ring is rotated 1 grid in a clockwise direction, the position of the character A in the middle ring of the encryption turntable is used as the rotation starting position, and the middle ring is rotated 1 grid in a counterclockwise direction.
[0138] In this embodiment, each time the encryption of a character in the preprocessed data is completed, the encryption mapping relationship and interference mapping relationship corresponding to each encryption dial in the encryption path are updated, which further increases the complexity of the encryption key, increases the difficulty of cracking the ciphertext, and thereby improves the encryption security.
[0139] Step S44: Update the encryption nodes on the encryption path.
[0140] Specifically, updating the encryption nodes on the encryption path includes:
[0141] When the encryption node where the encryption turntable is located is in an odd order in the encryption path, the encryption cube is rotated according to a first preset rotation rule, so as to update the encryption node on the encryption path;
[0142] When the encryption node where the encryption turntable is located is ranked in an even number in the encryption path, the encryption cube is rotated according to a second preset rotation rule, so as to update the encryption nodes on the encryption path.
[0143] Reference Figure 3 , Figure 3 Schematic diagram of the rotation form of the encryption cube of this application. In this embodiment, the rotation forms of the encryption cube include: Rr (representing the right side rotates r times 90 degrees clockwise), R`r (representing the right side rotates r times 90 degrees counterclockwise), Br (representing the back side rotates r times 90 degrees clockwise), B`r (representing the back side rotates r times 90 degrees counterclockwise), Fr (representing the front side rotates r times 90 degrees clockwise), F`r (representing the front side rotates r times 90 degrees counterclockwise), Lr (representing the left side rotates clockwise R`r (represents the left side rotates r times 90 degrees counterclockwise), L`r (represents the left side rotates r times 90 degrees counterclockwise), Ur (represents the top layer rotates r times 90 degrees clockwise), U`r (represents the top layer rotates r times 90 degrees counterclockwise), Dr (represents the bottom layer rotates r times 90 degrees clockwise), D`r (represents the bottom layer rotates r times 90 degrees counterclockwise), Mr (represents the middle layer rotates r times 90 degrees clockwise), M`r (represents the middle layer rotates r times 90 degrees counterclockwise).
[0144] The first preset rotation rule and the second preset rotation rule are composed of one or more combinations of the rotation forms of the above-mentioned encrypted Rubik's Cube. The selection of specific rotation forms and the order of combination can be set according to actual applications. For example, the first preset rotation rule includes: R (90 degrees clockwise rotation of the right side), F`2 (90 degrees counterclockwise rotation of the front side twice), M` (90 degrees counterclockwise rotation of the middle layer) and L (90 degrees clockwise rotation of the left side); the second preset rotation rule includes: U`2 (90 degrees counterclockwise rotation of the top layer twice), B2 (90 degrees clockwise rotation of the back side twice), R` (90 degrees counterclockwise rotation of the right side), L` (90 degrees counterclockwise rotation of the left side) and M (90 degrees clockwise rotation of the middle layer).
[0145] Step S45, determining whether there are unencrypted characters in the preprocessed data.
[0146] Step S46: If there are no unencrypted characters in the preprocessed data, the ciphertexts of the characters are sorted according to the order of the characters in the preprocessed data to obtain the ciphertexts of the target data.
[0147] Step S47, if there are unencrypted characters in the preprocessed data, return to the encryption mapping relationship corresponding to the encryption dial based on each encryption node in the encryption path, and encrypt the characters step by step according to the order of each encryption node in the encryption path to obtain the ciphertext of the characters.
[0148] It should be noted that, in this embodiment, the characters in the preprocessed data are encrypted by mapping and replacing the 64 characters corresponding to the Base64 encoding. The original text before encryption is the 64 characters corresponding to the Base64 encoding, and the final output ciphertext is still the 64 characters corresponding to the Base64 encoding. Therefore, it is difficult to determine what the original text is when cracking, which improves the concealment of the original text.
[0149] The decryption process of this embodiment can achieve decryption by reverse mapping along the encryption path according to the encryption process.
[0150] The present application embodiment provides an encryption device based on the magic cube, referring to Figure 4 , Figure 4 This is a functional module diagram of the first embodiment of the encryption device based on the magic cube of the present application.
[0151] In this embodiment, the magic cube-based encryption device includes:
[0152] Building module 10, used to build an encrypted Rubik's Cube;
[0153] A path determination module 20, used to determine an encryption path in the encryption cube based on a preset start encryption node and an end encryption node;
[0154] The data preprocessing module 30 is used to preprocess the target data to obtain preprocessed data;
[0155] The encryption module 40 is used to encrypt the characters in the preprocessed data one by one based on the encryption path to obtain the ciphertext of the target data.
[0156] Optionally, the building block is used to implement:
[0157] Construct the basic Rubik's Cube;
[0158] According to the turntable screening function, determining the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption turntable;
[0159] Determine the arrangement order of the characters of the middle ring of the encryption turntable according to the middle ring function of the turntable;
[0160] Based on the mapping relationship between the first ring, the second ring and the middle ring and the nodes of the basic Rubik's Cube, the encryption turntable of the nodes of the basic Rubik's Cube is determined to obtain an encrypted Rubik's Cube, wherein the characters of the first ring of the encryption turntable are mapped with the characters of the second ring of the encryption turntable to generate the encryption mapping relationship corresponding to the encryption turntable, and the characters of the middle ring of the encryption turntable are mapped with the characters of the first ring / second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable.
[0161] Optionally, the encryption module includes:
[0162] A character encryption unit, configured to map and encrypt the character level by level based on the encryption mapping relationship corresponding to the encryption disk of each encryption node in the encryption path and according to the order of each encryption node in the encryption path, so as to obtain the ciphertext of the character;
[0163] An encryption mapping relationship updating unit, used to update the encryption mapping relationship corresponding to the encryption disk of each encryption node;
[0164] An encryption node updating unit, used to update the encryption nodes on the encryption path;
[0165] The judgment unit is used to implement:
[0166] Determining whether there are unencrypted characters in the preprocessed data;
[0167] If there is no unencrypted character in the preprocessed data, sorting the ciphertext of the character according to the order of the character in the preprocessed data to obtain the ciphertext of the target data;
[0168] If there are unencrypted characters in the preprocessed data, the encryption mapping relationship corresponding to the encryption dial based on each encryption node in the encryption path is returned, and the characters are mapped and encrypted step by step according to the order of each encryption node in the encryption path to obtain the ciphertext of the characters.
[0169] Optionally, the encryption module further includes:
[0170] The encryption interference unit is used to determine the interference ciphertext corresponding to the character based on the interference mapping relationship corresponding to the encryption dial that terminates the encryption node in the encryption path, and combine the interference ciphertext into the ciphertext of the character.
[0171] Optionally, the encrypted mapping relationship updating unit is used to implement:
[0172] Determine the rotation starting position of the encryption turntable of each encryption node according to the turntable initialization function;
[0173] Determining the rotation characteristic data of the encryption turntable of each encryption node according to the turntable rotation function;
[0174] Based on the rotation starting position and the rotation characteristic data, the encryption mapping relationship corresponding to the encryption turntable of each encryption node is updated.
[0175] Optionally, the encryption node updating unit is used to implement:
[0176] When the order of the encryption node where the encryption turntable is located in the encryption path is an odd number, the encryption cube is rotated according to the first preset rotation rule;
[0177] When the encryption node where the encryption turntable is located is ranked in an even number in the encryption path, the encryption Rubik's Cube is rotated according to a second preset rotation rule.
[0178] Optionally, the data preprocessing module is used to implement:
[0179] The target data is preprocessed to obtain preprocessed data, wherein the preprocessed data is represented by 64 characters corresponding to the Base64 encoding.
[0180] The specific implementation of the Rubik's Cube-based encryption device of the present application is basically the same as the above-mentioned Rubik's Cube-based encryption method embodiments, and will not be repeated here.
[0181] An embodiment of the present application further provides a storage medium, on which a magic cube-based encryption program is stored. When the magic cube-based encryption program is executed by a processor, the steps of the magic cube-based encryption method described above are implemented.
[0182] The specific implementation method of the storage medium of the present application is basically the same as the above-mentioned embodiments of the magic cube-based encryption method, and will not be repeated here.
[0183] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0184] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0185] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0186] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A magic cube based encryption method, characterized in that: The encryption method based on the magic cube comprises the following steps: Build a crypto cube; Based on a preset starting encryption node and an ending encryption node, an encryption path is determined in the encryption cube; wherein different starting encryption nodes and ending encryption nodes correspond to different encryption paths in the encryption cube; Preprocessing the target data to obtain preprocessed data; Based on the encryption wheel corresponding to the encryption path, encrypt the characters in the preprocessed data one by one to obtain the ciphertext of the target data; The steps of constructing the encrypted Rubik's Cube include: Construct the basic Rubik's Cube; According to the turntable screening function, determining the arrangement order of the characters in the first ring and the arrangement order of the characters in the second ring of the encryption turntable; Determine the arrangement order of the characters of the middle ring of the encryption turntable according to the middle ring function of the turntable; Based on the mapping relationship between the first ring, the second ring and the middle ring and the nodes of the basic Rubik's Cube, the encryption turntable of the nodes of the basic Rubik's Cube is determined to obtain the encrypted Rubik's Cube.
2. The magic cube-based encryption method according to claim 1, characterized in that: The characters of the first ring of the encryption turntable are mapped with the characters of the second ring of the encryption turntable to generate the encryption mapping relationship corresponding to the encryption turntable, and the characters of the middle ring of the encryption turntable are mapped with the characters of the first ring / second ring of the encryption turntable to generate the interference mapping relationship corresponding to the encryption turntable.
3. The magic cube-based encryption method according to claim 1, characterized in that: The step of encrypting the characters in the preprocessed data one by one based on the encryption disk corresponding to the encryption path to obtain the ciphertext of the target data includes: Based on the encryption mapping relationship corresponding to the encryption disk of each encryption node in the encryption path, and according to the order of each encryption node in the encryption path, the character is mapped and encrypted step by step to obtain the ciphertext of the character; Updating the encryption mapping relationship corresponding to the encryption turntable of each encryption node; Updating the encryption nodes on the encryption path; Determining whether there are unencrypted characters in the preprocessed data; If there is no unencrypted character in the preprocessed data, sorting the ciphertext of the character according to the order of the character in the preprocessed data to obtain the ciphertext of the target data; If there are unencrypted characters in the preprocessed data, the encryption mapping relationship corresponding to the encryption dial based on each encryption node in the encryption path is returned, and the characters are mapped and encrypted step by step according to the order of each encryption node in the encryption path to obtain the ciphertext of the characters.
4. The magic cube-based encryption method according to claim 3, characterized in that: After the step of mapping and encrypting the characters step by step based on the encryption mapping relationship corresponding to the encryption disks of the encryption nodes in the encryption path and obtaining the ciphertext of the characters according to the order of the encryption nodes in the encryption path, the method further includes: Based on the interference mapping relationship corresponding to the encryption dial that terminates the encryption node in the encryption path, the interference ciphertext corresponding to the character is determined, and the interference ciphertext is combined with the ciphertext of the character.
5. The magic cube-based encryption method according to claim 3, characterized in that: The step of updating the encryption mapping relationship corresponding to the encryption turntable of each encryption node includes: Determine the rotation starting position of the encryption turntable of each encryption node according to the turntable initialization function; Determining the rotation characteristic data of the encryption turntable of each encryption node according to the turntable rotation function; Based on the rotation starting position and the rotation characteristic data, the encryption mapping relationship corresponding to the encryption turntable of each encryption node is updated.
6. The magic cube based encryption method as claimed in claim 3, characterized in that: The step of updating the encryption nodes on the encryption path includes: When the order of the encryption node where the encryption turntable is located in the encryption path is an odd number, the encryption cube is rotated according to the first preset rotation rule; When the encryption node where the encryption turntable is located is ranked in an even number in the encryption path, the encryption Rubik's Cube is rotated according to a second preset rotation rule.
7. The magic cube based encryption method according to claim 1, characterized in that: The step of preprocessing the target data to obtain preprocessed data includes: The target data is preprocessed to obtain preprocessed data, wherein the preprocessed data is represented by 64 characters corresponding to the Base64 encoding.
8. An encryption device based on a magic cube, characterized in that: The magic cube-based encryption device comprises: Building blocks for building crypto cubes; A path determination module, used to determine an encryption path in the encryption cube based on a preset start encryption node and an end encryption node; wherein different start encryption nodes and end encryption nodes correspond to different encryption paths in the encryption cube; A data preprocessing module is used to preprocess the target data to obtain preprocessed data; An encryption module, used to encrypt characters in the preprocessed data one by one based on the encryption disk corresponding to the encryption path to obtain the ciphertext of the target data; The construction module is also used to construct a basic Rubik's Cube; determine the arrangement order of characters in the first ring and the arrangement order of characters in the second ring of the encryption turntable according to the turntable screening function; determine the arrangement order of characters in the middle ring of the encryption turntable according to the turntable middle ring function; based on the mapping relationship between the first ring, the second ring and the middle ring and the nodes of the basic Rubik's Cube, determine the encryption turntable of the nodes of the basic Rubik's Cube to obtain the encrypted Rubik's Cube.
9. An encryption device based on a magic cube, characterized in that: The device comprises: a memory, a processor, and a magic cube-based encryption program stored in the memory and executable on the processor, wherein the magic cube-based encryption program is configured to implement the steps of the magic cube-based encryption method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a magic cube-based encryption program, and when the magic cube-based encryption program is executed by the processor, the steps of the magic cube-based encryption method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Magic cube encryption and decryption method
CN102752108A