A method, device, electronic device and storage medium for generating a substitution table

By selecting target elements from the initial permutation table to generate a target permutation table, the problem of low permutation table generation efficiency in the prior art is solved, and efficient and secure data encryption effect is achieved.

CN118523900BActive Publication Date: 2025-09-05BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410758676.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2025-09-05
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

The existing technology has low efficiency in generating a substitution table and can only generate one new substitution table, which is difficult to meet the requirements of efficient data encryption.

Method used

A target permutation table is generated by selecting a target element from an initial permutation table generated based on a key, ensuring that there are no duplicate elements in the initial permutation table and that the number of elements is greater than that in the target permutation table, selecting the target element or the row-column intersection element using a preset direction, and determining the input and output elements of the target permutation table.

Benefits of technology

The efficiency and unpredictability of the permutation table generation are improved, the randomness and security of the permutation table are ensured, and it is suitable for data encryption of different sizes and types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118523900B_ABST
    Figure CN118523900B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device, and storage medium for generating a permutation table, belonging to the field of information security technology. The method comprises: determining the number of elements in a target permutation table, the target permutation table being used to encrypt data; selecting a target element from an initial permutation table, the number of target elements being equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table contains no duplicate elements, and the number of elements is greater than the number of elements in the target permutation table; and determining a target permutation table based on the target element. In this way, a target element can be arbitrarily selected from the initial permutation table based on the number of elements in the target permutation table, and a target permutation table can be generated, thereby ensuring the unpredictability of the permutation table and improving the efficiency of permutation table generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security technology, and in particular to a method, device, electronic device and storage medium for generating a substitution table. Background Art

[0002] With the rapid development of communications and computer technology, data encryption has become the norm. Block ciphers and stream ciphers are generally considered the mainstream algorithms in data encryption. Permutation S-boxes (or permutation tables), used to implement nonlinear transformations, are a key component of symmetric encryption algorithms and play a vital role in ensuring their security.

[0003] In the prior art, some permutation tables are randomly generated by the interaction of a key and a generation method. This generation method generally first provides an initial permutation table, and then, according to preset rules, the positions of the elements in the initial permutation table are moved or exchanged multiple times to obtain a new permutation table that is different from the initial permutation table. However, this generation method is complex and can only produce one new permutation table, resulting in low generation efficiency. Summary of the Invention

[0004] Embodiments of the present application provide a method, device, electronic device, and storage medium for generating a substitution table to improve the efficiency of generating a substitution table.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a substitution table, comprising:

[0006] determining the number of elements of a target permutation table, wherein the target permutation table is used to encrypt the data;

[0007] Selecting target elements from an initial permutation table, the number of target elements being equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table does not contain duplicate elements and the number of elements in the initial permutation table is greater than the number of elements in the target permutation table;

[0008] The target permutation table is determined according to the target element.

[0009] In some embodiments, selecting target elements from the initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, comprises:

[0010] A first element is selected from the initial permutation table, and N elements are selected along a preset direction with the first element as a starting point, where N is equal to the number of elements in the target permutation table; the N elements are the target elements.

[0011] In some embodiments, selecting target elements from the initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, comprises:

[0012] Selecting a target row and a target column from the initial permutation table;

[0013] An element corresponding to an intersection of the target row and the target column on the initial permutation table is determined as the target element, and a product of the target row and the target column is not less than the number of elements in the target permutation table.

[0014] In some embodiments, determining the target permutation table according to the target element includes:

[0015] Determining an input element of the target permutation table and an output element of the input element according to the target element; the input element refers to a serial number of the target element, and the serial number is determined according to a selection order of the target element; and the output element is determined according to a numerical value of the target element;

[0016] The target permutation table is determined based on the input element and the output element.

[0017] In some embodiments, the method further comprises:

[0018] If the target substitution table is used to encrypt character data, the input elements and the output elements in the target substitution table are represented as corresponding characters; the characters are determined according to the arrangement order of the character data.

[0019] In some embodiments, the method further comprises:

[0020] Based on a preset display style of the substitution table, the target substitution table is output.

[0021] In a second aspect, an embodiment of the present application provides a substitution table generating device, comprising:

[0022] A first determining module is used to determine the number of elements in a target permutation table, wherein the target permutation table is used to encrypt data;

[0023] a selection module for selecting target elements from an initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table does not contain duplicate elements and the number of elements in the initial permutation table is greater than the number of elements in the target permutation table;

[0024] The second determining module is configured to determine the target permutation table according to the target element.

[0025] In some embodiments, the selection module is specifically configured to:

[0026] A first element is selected from the initial permutation table, and N elements are selected along a preset direction with the first element as a starting point, where N is equal to the number of elements in the target permutation table; the N elements are the target elements.

[0027] In some embodiments, the selection module is specifically configured to:

[0028] Selecting a target row and a target column from the initial permutation table;

[0029] An element corresponding to an intersection of the target row and the target column on the initial permutation table is determined as the target element, and a product of the target row and the target column is not less than the number of elements in the target permutation table.

[0030] In some embodiments, the second determining module is specifically configured to:

[0031] Determining an input element of the target permutation table and an output element of the input element according to the target element; the input element refers to a serial number of the target element, and the serial number is determined according to a selection order of the target element; and the output element is determined according to a numerical value of the target element;

[0032] The target permutation table is determined based on the input element and the output element.

[0033] In some embodiments, further comprising:

[0034] A replacement module is used to represent the input elements and the output elements in the target replacement table as corresponding characters if the target replacement table is used to encrypt character data; the characters are determined according to the arrangement order of the character data.

[0035] In some embodiments, further comprising:

[0036] The output module is used to output the target substitution table based on a preset substitution table display style.

[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:

[0038] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the above-mentioned substitution table generation method.

[0039] In a fourth aspect, an embodiment of the present application provides a storage medium. When a computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the above-mentioned substitution table generation method.

[0040] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when called and executed by an electronic device, enables the electronic device to execute the above-mentioned substitution table generation method.

[0041] In an embodiment of the present application, the number of elements in a target permutation table is determined, and the target permutation table is used to encrypt data. A target element is selected from an initial permutation table, and the number of target elements is equal to the number of elements in the target permutation table. The initial permutation table is generated based on a key, has no duplicate elements, and has a greater number of elements than the target permutation table. In this way, a target element can be arbitrarily selected from the initial permutation table based on the number of elements in the target permutation table, and a target permutation table can be generated. This ensures the unpredictability of the permutation table and improves the efficiency of generating the permutation table.

[0042] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. The purposes and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0044] Figure 1 A flowchart of a method for generating a substitution table provided in an embodiment of the present application;

[0045] Figure 2 This is a 100 yuan replacement symbol provided in the embodiment of the present application;

[0046] Figure 3 A schematic diagram of a 26-element substitution representation provided in an embodiment of the present application;

[0047] Figure 4 A target replacement representation provided in an embodiment of the present application;

[0048] Figure 5 A schematic structural diagram of a substitution table generating device provided in an embodiment of the present application;

[0049] Figure 6A schematic diagram of the hardware structure of an electronic device for implementing a method for generating a substitution table provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to improve the efficiency of generating a substitution table, embodiments of the present application provide a substitution table generation method, device, electronic device, and storage medium.

[0051] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application can be combined with each other if there is no conflict.

[0052] It should be noted that the terms "first", "second" etc. in the description of the embodiments of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0053] With the rapid development of communications and computer technology, data encryption has become the norm. Block ciphers, such as the Advanced Encryption Standard (AES) and the Data Encryption Standard (DES), and stream ciphers, such as the RC4 algorithm, are often used in data encryption. Permutation S-boxes (or permutation tables), used to implement nonlinear transformations, are crucial components of symmetric encryption algorithms, performing permutation operations and playing a vital role in ensuring their security.

[0054] In the prior art, some permutation tables can be randomly generated by the combined action of a key and a generation method, making the generated permutation table random and unpredictable, making it difficult for attackers to infer or predict it. Currently, a popular method for generating a permutation table is to first provide an initial permutation table, and then, under the action of a key, the positions of the elements in the initial permutation table are moved or exchanged multiple times according to preset rules to obtain a new permutation table that is different from the initial permutation table. However, this generation method is complex and can only generate one new permutation table, resulting in low generation efficiency.

[0055] In order to solve the above problems, the present application proposes a method, device, electronic device and storage medium for generating a substitution table to improve the efficiency of generating the substitution table.

[0056] The specific implementation of the substitution table generation proposed in this application is described below with specific examples. Figure 1 This is a flowchart of a substitution table generation method provided in an embodiment of the present application. The method can be implemented by a substitution table generation device, and the method includes the following steps.

[0057] In step 101, the number of elements of a target permutation table is determined, where the target permutation table is used to encrypt data.

[0058] In specific implementation, permutation refers to any operation performed on data by any system or device. If the input data during the operation is different, the operation result must be different, and the input data and the data operation result belong to the same set. For example, 8-input and 8-output permutation can mean that any 8-bit data is input into the system, and the system outputs an 8-bit data processing result. The permutation table generating device can determine the number of elements of the target permutation table according to the user's generation requirements. For example, the user's requirement is to adapt to a target permutation table similar to the block cipher algorithm AES. The block cipher algorithm AES usually uses a permutation table with 8-bit input and 8-bit output. The number of elements of the target permutation table is 256. For another example, the user's requirement is to encrypt the mobile phone number in the plaintext data. The number of elements of the target permutation table is 10 or 100. The permutation table generating device can also determine the number of elements of the target permutation table according to the number of elements specified by the user. For example, if the number of elements specified by the user is 100, the number of elements of the target permutation table is 100.

[0059] Figure 2 A 100 yuan replacement representation is provided for the embodiment of the present application, such as Figure 2 As shown, the permutation table is a permutation table that replaces 0 to 99 with numbers between 0 and 99, where the numbers in the solid box are input elements, that is, the first row (0 to 9) and the first column (0 to 9) are input elements, and the numbers in the dotted box are the output elements corresponding to the input elements. For example, S

[01] = 86, which means that the input element is "01" and the output element is "86". Similarly, S

[02] = 78, S

[41] = 85, S

[98] = 16, etc., and by Figure 2 It can be seen that the output elements are a random arrangement from 0 to 99.

[0060] For example, Figure 3 A 26-element substitution representation is provided for the embodiment of the present application, such as Figure 3As shown in , the permutation table is a permutation table that replaces numbers between 0 and 25 with numbers between 0 and 25. The first row is the input element and the second row is the input element. Figure 3 It can be seen that the output elements are a random arrangement from 0 to 25.

[0061] Among them, the display styles of the substitution table are diverse, and can be determined based on the number of elements, user needs, etc.

[0062] In step 102, target elements are selected from an initial permutation table, where the number of target elements is equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, has no duplicate elements, and has a greater number of elements than the target permutation table.

[0063] In specific implementation, the initial permutation table can be pre-selected or generated by using existing technology using a key and a generation method. For example, a 20-bit block cipher algorithm is used to convert all plaintexts (0, 1, 2, ..., 2 20 -1) encryption, and obtain an initial permutation table with 1048576 elements, wherein all plaintexts and the ciphertexts corresponding to all plaintexts can also be represented as five hexadecimal numbers 0x00000-0xFFFFF. For example, using a 16-bit block cipher algorithm, all plaintexts (0, 1, 2, ..., 2 16 -1) encryption, an initial permutation table with 65536 elements can be obtained. In this way, when the size of the target permutation table is much smaller than 65536, the number of elements in the initial permutation table can be made larger than the number of elements in the target permutation table, which can ensure that the number of target elements selected from the initial permutation table is equal to the number of elements in the target permutation table. In addition, since the elements in the initial permutation table are arranged in random order and there are no duplicate elements in the initial permutation table, the randomness and unpredictability of the target permutation table are also guaranteed.

[0064] In actual applications, the initial permutation table may be expressed in various forms, such as a rectangle, a square, all elements arranged in a row, or all elements arranged in a column. The specific form of the initial permutation table can be set by technical personnel according to specific needs, and this application does not limit this.

[0065] Assume that the number of elements in the initial permutation table is 1048576. If the initial permutation table is expressed in a square form, it can be 1024 rows * 1024 columns. If the initial permutation table is expressed in a rectangular form, it can be 16 rows * 65536 columns or 16 columns * 65536 rows. You can also arrange 1048576 elements into a row or arrange 1048576 elements into a column.

[0066] In a specific implementation, after the initial permutation table is determined, the target element may be selected from the initial permutation table according to a preset selection rule based on the number of elements in the target permutation table.

[0067] In specific implementation, the preset selection rule may be to select the first element from the initial permutation table, and starting from the first element, select N elements along a preset direction, where N is equal to the number of elements in the target permutation table; and the N elements are target elements.

[0068] Among them, the preset direction can be determined according to the form of expression of the initial permutation table. For example, if the initial permutation table is a square or a rectangle, then the preset directions include up, down, left, and right. For example, if the initial permutation table is for all elements to be arranged in a row, then the preset directions include left and right. For example, if the initial permutation table is for all elements to be arranged in a column, then the preset directions include up, down, etc.

[0069] Assume that the number of elements in the initial permutation table A is 1048576, and it is a permutation table of 1024 rows * 1024 columns, where the minimum element of the initial permutation table A is 0 and the maximum element is 1048575. You want to generate a 256-element target permutation table a with 8-bit input and 8-bit output, that is, the number of elements N in the target permutation table a is equal to 256. Then, you can first select the first element from the initial permutation table A, such as taking the element corresponding to the 10th row and 10th column as the first element, and downward as the preset direction, where the position of the first element is the first row and first column. Then you can take the element corresponding to the 10th row and 10th column as the starting point, and select 256 elements downward, such as selecting 256 elements continuously or selecting 256 elements at intervals of the preset number of elements, such as selecting one every 2 elements. This application does not limit this.

[0070] In addition, in the process of selecting N elements along the preset direction, if the first element is not selected properly, it may be impossible to select the next element in the preset direction. For example, starting from the element corresponding to the 10th row and 10th column as the first element, the selection is continued upward. When the 10th element is selected, the edge of the initial permutation table A is reached, and the next element cannot be selected upward. At this time, keeping the selection direction unchanged, you can continue to select the remaining elements from the element in the 1023rd row and 11th column, or you can continue to select the remaining elements from the element in the 1023rd row and 9th column, until all 256 elements are selected.

[0071] Suppose again that the initial permutation table A has 1048576 elements and is a permutation table in which all elements are arranged in 1 row. The minimum element of the initial permutation table A is 0 and the maximum element is 1048575. The number of elements N in the target permutation table a is 256. Then, you can first select the first element from the initial permutation table A. The preset direction can be left or right. For example, with the 10th element as the first element and the preset direction is right, you can start from the 10th element and select 256 elements to the right, such as continuously selecting 256 elements or selecting 256 elements at intervals of the preset number of elements. The number of element intervals is not limited. When the preset direction is to the left, if you select continuously, when you select the 10th element, you reach the edge of the initial permutation table A and you can no longer select the next element to the left. At this time, keep the selection direction unchanged, and you can continue to select the next element to the left from the last element of the initial permutation table A until all 256 elements are selected.

[0072] During specific implementation, in order to speed up the selection efficiency of the target element, the preset selection rule can also be to select the target row and target column from the initial permutation table, and determine the element corresponding to the intersection of the target row and target column on the initial permutation table as the target element, and the product of the target row and the target column is not less than the number of elements in the target permutation table.

[0073] For example, still taking the initial permutation table A with 1048576 elements, 1024 rows * 1024 columns, the minimum element is 0, and the maximum element is 1048575, we want to generate a 256-element target permutation table a with 8-bit input and 8-bit output, that is, the number of elements N of the target permutation table a is equal to 256. As an example, since the number of elements in the target permutation table is 256, 16 target rows can be selected from the 1024 rows of the initial permutation table A, and 16 target columns can be selected from the 1024 columns of the initial permutation table A. Then, the 256 elements at the intersection of these 16 rows and 16 columns are determined as target elements. Alternatively, 8 target rows can be selected from the 1024 rows of the initial permutation table A, and 32 target columns can be selected from the 1024 columns of the initial permutation table A. Then, the 256 elements at the intersection of these 8 rows and 32 columns are determined as target elements, where the product of the target row and the target column is not less than the number of elements in the target permutation table.

[0074] For another example, if the initial permutation table is the initial permutation table A, and we want to generate a 4096-element target permutation table b with 12-bit input and 12-bit output, that is, the number of elements N in the target permutation table b is equal to 4096, we can select 64 target rows from the 1024 rows of the initial permutation table A, and select 64 target columns from the 1024 columns of the initial permutation table A, and then determine the 4096 elements at the intersection of these 64 rows and 64 columns as the target elements, or select 32 target elements from the 1024 rows of the initial permutation table A. The target rows are marked, and 128 target columns are selected from the 1024 columns of the initial permutation table A. Then, 4096 elements at the intersection of these 32 rows and 128 columns are determined as target elements, wherein the product of the target row and the target column is not less than the number of elements in the target permutation table, and the target rows and target columns can be selected by starting from the first row and selecting a row every 2 rows, and starting from the first column and selecting a column every 2 columns. There are many ways to select the target rows and target columns, and this application does not limit this.

[0075] In this way, since there are many choices of rows and columns, a variety of different permutation tables can be randomly generated, making the permutation table quite unpredictable.

[0076] During specific implementation, the above method can also be used to generate multiple target permutation tables at one time. For example, taking the initial permutation table as the initial permutation table A, if you want to generate 10 676-tuple target permutation tables c, you can select the first element from the initial permutation table A, and use the first element as the starting point to select 6760 elements along the preset direction to form 10 676-tuple groups. You can also select 10 rows and 676 columns, and use each row as a target permutation table c, or select 10 columns and 676 rows, and use each column as a target permutation table c. It should be noted that the specific target row and target column selection method can be set by technical personnel, and this application does not limit this.

[0077] In step 103, a target permutation table is determined according to the target element.

[0078] During specific implementation, the input element of the target permutation table and the output element of the input element can be determined according to the target element; wherein the input element refers to the serial number of the target element, and the serial number is determined according to the selection order of the target element; the output element is determined according to the numerical size of the target element, and then the target permutation table is determined based on the input element and the output element.

[0079] For example, the target permutation table d is a 10-element permutation table from 0 to 9, and the target elements selected from the initial permutation table A are {100, 568, 48, 962, 52, 856, 85, 361, 225, 156}, then the input elements of the target permutation table are {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, and the element with the largest value in the target element corresponds to the element with the largest value in the target permutation table, and the element with the smallest value in the target element corresponds to the element with the smallest value in the target permutation table. Based on the value of the target element, it can be seen that the order of the elements in the target element from small to large is (962, 856, 568, 361, 225, 156, 100, 85, 52, 48 ), it can be seen that the element "962" with the largest value corresponds to the output element "9", then the element "856" corresponds to the output element "8", the element "568" corresponds to the output element "7", the element "361" corresponds to the output element "6", the element "225" corresponds to the output element "5", the element "156" corresponds to the output element "4", the element "100" corresponds to the output element "3", the element "85" corresponds to the output element "2", the element "52" corresponds to the output element "1", and the element "48" with the smallest value corresponds to the output element "0". Therefore, according to the selection order of the target elements, the output elements of the target permutation table d are {3, 7, 0, 9, 1, 8, 2, 6, 5, 4}. Therefore, the target permutation table d is as follows Figure 4 As shown, Figure 4 This is a target replacement representation provided in an embodiment of the present application.

[0080] In a specific implementation, if the target substitution table is used to encrypt character data, the input elements and output elements in the target substitution table can be represented as corresponding characters; wherein the characters are determined according to the arrangement order of the character data.

[0081] For example, if the target permutation table is used to encrypt English letters in plain text, 26 target elements can be selected from the initial permutation table to generate a 26-element target permutation table. Assume that the generated 26-element target permutation table is as follows: Figure 3 As shown, the input elements and output elements can be represented as corresponding characters according to the order of arrangement of English letters, namely A, B, C, D, ..., X, Y, Z, that is, element "0" is represented as "A", element "1" is represented as "B", element "19" is represented as "T", element "25" is represented as "Z", and so on. This application does not list them one by one here.

[0082] Afterwards, the target substitution table can be output based on the preset substitution table display style, wherein the preset display style is, for example, Figure 2 As shown, or as Figure 3 As shown, it can be set according to user needs, and this application does not limit it here.

[0083] Based on the same technical concept, an embodiment of the present application also provides a substitution table generation device. The principle of solving the problem by the substitution table generation device is similar to that of the above-mentioned substitution table generation method. Therefore, the implementation of the substitution table generation device can refer to the implementation of the substitution table generation method, and the repeated parts will not be repeated.

[0084] Figure 5 A schematic structural diagram of a substitution table generating device provided in an embodiment of the present application includes a first determination module 501 , a selection module 502 , and a second determination module 503 .

[0085] A first determining module 501 is configured to determine the number of elements in a target permutation table, wherein the target permutation table is used for encrypting data;

[0086] A selection module 502 is configured to select target elements from an initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table does not contain duplicate elements and the number of elements in the initial permutation table is greater than the number of elements in the target permutation table;

[0087] The second determining module 503 is configured to determine the target permutation table according to the target element.

[0088] In some embodiments, the selection module 502 is specifically configured to:

[0089] A first element is selected from the initial permutation table, and N elements are selected along a preset direction with the first element as a starting point, where N is equal to the number of elements in the target permutation table; the N elements are the target elements.

[0090] In some embodiments, the selection module 502 is specifically configured to:

[0091] Selecting a target row and a target column from the initial permutation table;

[0092] An element corresponding to an intersection of the target row and the target column on the initial permutation table is determined as the target element, and a product of the target row and the target column is not less than the number of elements in the target permutation table.

[0093] In some embodiments, the second determining module 503 is specifically configured to:

[0094] Determining an input element of the target permutation table and an output element of the input element according to the target element; the input element refers to a serial number of the target element, and the serial number is determined according to a selection order of the target element; and the output element is determined according to a numerical value of the target element;

[0095] The target permutation table is determined based on the input element and the output element.

[0096] In some embodiments, further comprising:

[0097] The replacement module 504 is used to represent the input elements and the output elements in the target replacement table as corresponding characters if the target replacement table is used to encrypt character data; the characters are determined according to the arrangement order of the character data.

[0098] In some embodiments, further comprising:

[0099] The output module 505 is configured to output the target substitution table based on a preset substitution table display style.

[0100] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated into one processor, or may exist physically separately, or two or more modules may be integrated into one module. The coupling between the modules can be achieved through some interfaces, which are usually electrical communication interfaces, but it is not ruled out that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules.

[0101] After introducing the substitution table generation method and apparatus according to an exemplary embodiment of the present application, an electronic device according to another exemplary embodiment of the present application will be introduced next.

[0102] Refer to the following Figure 6 The electronic device 130 implemented according to this embodiment of the present application is described. Figure 6 The electronic device 130 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.

[0103] like Figure 6 As shown, the electronic device 130 is a general electronic device. Components of the electronic device 130 may include, but are not limited to, the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).

[0104] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, and a processor or local bus using any of a variety of bus architectures.

[0105] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .

[0106] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0107] The electronic device 130 may also communicate with one or more external devices 134 (e.g., a keyboard, pointing device, etc.), one or more devices that enable a user to interact with the electronic device 130, and / or any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., a router, a modem, etc.). Such communication may occur via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules of the electronic device 130 via a bus 133. It should be understood that, although not shown, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0108] In an exemplary embodiment, a storage medium is also provided. When a computer program in the storage medium is executed by a processor of an electronic device, the electronic device can perform the above-mentioned method for generating a substitution table. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0109] In an exemplary embodiment, the electronic device of the present application may include at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor can execute the steps of any substitution table generation method provided in the embodiments of the present application.

[0110] In an exemplary embodiment, a computer program product is further provided. When the computer program product is executed by an electronic device, the electronic device can implement any exemplary method provided in this application.

[0111] Furthermore, the computer program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0112] In the embodiment of the present application, the program product for generating a substitution table can be implemented as a CD-ROM and include program code, and can be run on a computing device. However, the program product of the present application is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0113] A readable signal medium may include a data signal transmitted in baseband or as part of a carrier wave, which carries readable program code. Such a transmitted data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0114] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0115] The program code for performing the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0116] It should be noted that although several units or subunits of the device are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, depending on the embodiment of the application, the features and functions of two or more units described above can be embodied in a single unit. Conversely, the features and functions of a single unit described above can be further divided and embodied by multiple units.

[0117] Furthermore, although the operations of the method of the present application are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in this particular order, or that all illustrated operations must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0118] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0119] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0120] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0122] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.

[0123] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A method for generating a substitution table, characterized in that: include: determining the number of elements of a target permutation table, wherein the target permutation table is used to encrypt the data; Selecting target elements from an initial permutation table, the number of target elements being equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table does not contain duplicate elements and the number of elements in the initial permutation table is greater than the number of elements in the target permutation table; Determine the target permutation table according to the target element and the logic rule; The determining the target permutation table according to the target element and the logic rule includes: Determining input elements of the target permutation table and output elements of the input elements according to the number and position order of the target elements; the input elements refer to serial numbers of the target elements, and the serial numbers are determined according to the selection order of the target elements; the output elements are determined by: sorting the target elements according to a preset arrangement rule according to their numerical values ​​to obtain a first order, and sorting the input elements according to a preset arrangement rule according to their numerical values ​​to obtain a second order, determining a correspondence between the target elements and the sorted input elements according to the correspondence between the elements with the same position in the first order and the second order, and outputting the output elements according to the position order of the target elements based on the correspondence between the target elements and the sorted input elements; The target permutation table is determined based on the input element and the output element.

2. The method according to claim 1, wherein The step of selecting target elements from the initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, comprises: A first element is selected from the initial permutation table, and N elements are selected along a preset direction with the first element as a starting point, where N is equal to the number of elements in the target permutation table; the N elements are the target elements.

3. The method according to claim 1, wherein The step of selecting target elements from the initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, comprises: Selecting a target row and a target column from the initial permutation table; An element corresponding to an intersection of the target row and the target column on the initial permutation table is determined as the target element, and a product of the target row and the target column is not less than the number of elements in the target permutation table.

4. The method according to claim 1, wherein The method further comprises: If the target substitution table is used to encrypt character data, the input elements and the output elements in the target substitution table are represented as corresponding characters; the characters are determined according to the arrangement order of the character data.

5. The method according to claim 1, wherein The method further comprises: Based on a preset display style of the substitution table, the target substitution table is output.

6. A substitution table generating device, characterized in that: include: A first determining module is used to determine the number of elements in a target permutation table, wherein the target permutation table is used to encrypt data; a selection module for selecting target elements from an initial permutation table, wherein the number of target elements is equal to the number of elements in the target permutation table, wherein the initial permutation table is generated based on a key, the initial permutation table does not contain duplicate elements and the number of elements in the initial permutation table is greater than the number of elements in the target permutation table; A second determining module, configured to determine the target permutation table according to the target element and a logic rule; The second determining module is specifically configured to: Determining input elements of the target permutation table and output elements of the input elements according to the number and position order of the target elements; the input elements refer to serial numbers of the target elements, and the serial numbers are determined according to the selection order of the target elements; the output elements are determined by: sorting the target elements according to a preset arrangement rule according to their numerical values ​​to obtain a first order, and sorting the input elements according to a preset arrangement rule according to their numerical values ​​to obtain a second order, determining a correspondence between the target elements and the sorted input elements according to the correspondence between the elements with the same position in the first order and the second order, and outputting the output elements according to the position order of the target elements based on the correspondence between the target elements and the sorted input elements; The target permutation table is determined based on the input element and the output element.

7. The device according to claim 6, characterized in that The selection module is specifically used to: A first element is selected from the initial permutation table, and N elements are selected along a preset direction with the first element as a starting point, where N is equal to the number of elements in the target permutation table; the N elements are the target elements.

8. The device according to claim 6, wherein The selection module is specifically used to: Selecting a target row and a target column from the initial permutation table; An element corresponding to an intersection of the target row and the target column on the initial permutation table is determined as the target element, and a product of the target row and the target column is not less than the number of elements in the target permutation table.

9. The device according to claim 6, wherein Also includes: A replacement module is used to represent the input elements and the output elements in the target replacement table as corresponding characters if the target replacement table is used to encrypt character data; the characters are determined according to the arrangement order of the character data.

10. The device according to claim 6, wherein Also includes: The output module is used to output the target substitution table based on a preset substitution table display style.

11. An electronic device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor, wherein: The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.

12. A storage medium, characterized in that: When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can perform the method according to any one of claims 1 to 5.

13. A computer program product, characterized in that When the computer program product is called and executed by an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Bank data encryption method, device and system and medium

    CN116663025A