Implementing the DES plus decision algorithm (3) - Decryption

zhaozj2021-02-16  58

'scode to solve the deword string' SKEY key string PUBLIC SUB DES_DECode (byref scode () as Byte, byval skey as string, byref breturn () AS BYTE) Attribute DES_DECODE.VB_DESCRIPTION = "Decryption Scode: Cipheet 16 BRT SKEY: Key Text, Top 8 Valid Breturn: Ming Text 16 Brand "DIM LENTIMES AS Integer '] AS BYTE' 64-bit Binary Original Key DIM KeyPC_1 (55) AS BYTE 'Store 56-bit Keys DIM Tempcode (7) AS BYTE' Store 8-bit Original Ciphext Dim Tempreturn (7) AS BYTE 'Store 8 Binding Dim Bincode (63) AS BYTE' Store 64-bit Ming Document DIM Codeip (63) AS BYTE 'Store IP Displacement Results DIM CODEE (47) AS BYTE' E Expansion Results DIM CODEP (31) AS BYTE 'P Transform Result DIM RETS (47) AS BYTE' S Box Operation 32 - bit Result DIM S 7) AS BYTE '

S-box operation 8 results DIM CODES1 (5) AS BYTE: DIM CODES2 (5) AS BYTE: DIM CODES4 (5) AS BYTE DIM CODES5 (5) AS BYTE: DIM CODES6 (5) AS BYTE: DIM CODES7 (5) AS BYTE: DIM CODES8 (5) AS BYTE DIM L0 (31) AS BYTE: DIM R0 (31) AS BYTE DIM L1 (31) AS BYTE: DIM R1 (31) AS BYTE DIM L2 (31) AS BYTE: DIM R2 (31) AS BYTE DIM L3 (31) AS BYTE: DIM R3 (31) AS BYTE: DIM R4 (31) AS BYTE DIM L5 (31) AS BYTE : DIM R5 (31) AS BYTE DIM L6 (31) AS BYTE: DIM R6 (31) AS BYTE DIM L7 (31) AS BYTE: DIM R7 (31) AS BYTE DIM L8 (31) AS BYTE: DIM R8 (31 AS BYTE DIM L9 (31) AS BYTE: DIM R9 (31) AS BYTE: DIM R10 (31) AS BYTE DIM L11 (31) AS BYTE: DIM R11 (31) AS BYTE DIM L12 (31) AS BYTE: DIM R12 (31) AS BYTE: DIM R13 (31) AS BYTE DIM L14 (31) AS BYTE: DIM R14 (31) AS BYTE DIM L15 (31) AS BYTE : DIM R15 (31) AS BYTE DIM L16 (31) AS BYTE: DIM R16 (31) AS BYTE DIM C0 (27) AS BYTE: DIM D0 (27) AS BYTE '16 Keys DIM C1 (27) AS BYTE: DIM D2 (27) AS BYTE: DIM C4 (27) AS BYTE: DIM D3 (27) AS BYTE: DIM D3 (27) AS BYTE: DIM D3 (27) AS BYTE: DIM C4 ( 27) AS BYTE: DIM D5 (27) AS BYTE: DIM C6 (27) AS BYTE: DIM D6 (27) AS BYTE: DIM D6 (27) AS BYTE: DIM D6 (27) AS BYTE: DIM D6 (27) AS BYTE: DIM C7 (27) AS BYTE: DIM C8 (27) AS BYTE: DIM D8 (27) AS BYTE: DIM D9 (27) AS BYTE: DIM D9 (27) AS BYTE: DIM C10 (27) AS BYTE : DIM D10 (27) AS BYTE: DIM D11 (27) AS BYTE: DIM C12 (27) AS BYTE: DIM D12 (27) AS BYTE: DIM C13 (27) AS BYTE: DIM D13 (27) AS BYTE: DIM C14 (27) AS BYTE: DIM C15 (27) AS BYTE: DIM D15 (27) AS BYTE: DIM C16 (27) AS BYTE: DIM D16 ( 27) AS BYTE: DIM C_D (55) AS BYTE '

CN, DN merged storage DIM K1 (47) AS BYTE: DIM K3 (47) AS BYTE: DIM K4 (47) AS BYTE: DIM K5 (47) AS BYTE: DIM K5 (47) AS BYTE: DIM K6 (47) AS BYTE: DIM K1 (47) AS BYTE: DIM K10 (47) AS BYTE: DIM K10 (47) AS BYTE: DIM K11 (47) AS BYTE: DIM K11 (47) AS BYTE: DIM K12 (47 AS BYTE: DIM K13 (47) AS BYTE: DIM K14 (47) AS BYTE: DIM K15 (47) AS BYTE: DIM K16 (47) AS BYTE: DIM I AS INTEGER DIM J AS INTEGER ' 8-byte tempkey = strconv (SKEY, VBFROMUNICODE) Redim Preserve Tempkey (7) for i = 0 to 7 binkey (i * 8 0) = (Tempkey (i) and & h80) / & h80 binkey (i * 8 1) = (Tempkey (i) and & h40) / & H40 binkey (i * 8 2) = (Tempkey (i) and & H20) / & H20 binkey (i * 8 3) = (TempKey (i) and & h10) / & H10 BinKey (i * 8 4) = (Tempkey (i) and & h8) / & H8 binkey (i * 8 5) = (Tempkey (i) and & h4) / & H4 binkey (i * 8 6) = (TempKey ) And & h2) / & h2 binkey (i * 8 7) = (Tempkey (i) and & h1) / & h1 next 'pc_1 conversion for i = 0 to 55 keypc _1 (i) = binkey (pc_1 (i)) NEXT 'to generate C0, D0 for i = 0 to 27 c0 (i) = keypc_1 (i) d0 (i) = keypc_1 (i 28) Next' **** ********************************************* K1 'generation C1, D1 for i = 0 to 26 C1 (i) = c0 (i LSI (1)) D1 (i) = d0 (i LSI (1)) NEXT C1 (27) = c0 (0) D1 (27 ) = D0 (0) 'combination C1, D1 is c_d for i = 0 to 27 c_d (i) = C1 (i) c_d (i) = 0 converted, generate K1 for i = 0 TO 47 K1 (i) =

C_D (PC_2 (I)) Next '**************************************************** ********** k2 'generates C2, D2 FOR i = 0 to 26 C2 (i) = C1 (i LSI (2)) D2 (i) = D1 (i LSI (2)) NEXT C2 (27) = C1 (0) D2 (27) = D1 (0) combination C2, D2 is C_D for i = 0 to 27 c_d (i) = C2 (I) C_D (i 28) = D2 ( I) Next 'PC_2 conversion, generate K2 for i = 0 to 47 k2 (i) = c_d (PC_2 (I)) Next' ******************** ****************************** K3 'to generate C3, D3 for i = 0 to 25 c3 (i) = C2 (i LSI (3)) D3 (i) = D2 (i LSI (3)) Next C3 (26) = C2 (0) D3 (26) = D2 (0) C3 (27) = C2 (1) D3 ( 27) = D2 (1) 'Combination C3, D3 is C_D for i = 0 to 27 c_d (i) = C3 (i) C_D (i) = D3 (i) Next' PC_2 conversion, generate K3 for i = 0 TO 47 K3 (I) = C_D (PC_2 (I)) Next '***************************************** ****************** K4 'to generate C4, D4 for i = 0 to 25 C4 (i) = c3 (i LSI (4)) D4 (i) = D3 (i lsi (4)) Next C4 (26) = C3 (0) D4 (26) = D3 (0) C4 (27) = C3 (1) D4 (27) = D3 (1) 'Combination C4, D4 C_D for i = 0 to 27 c_d (i) = C4 (I) C_D (i 28) = D4 (i) Next' PC_2 Conversion, generating K4 for i = 0 to 47 k4 (i) = c_d (PC_2 (I)) Next '************************* ************************* K5 'to generate C5, D5 for i = 0 to 25 C5 (i) = C4 (i lsi (5) ) D5 (i) = D4 (i lsi (5)) Next C5 (26) = C4 (0) D5 (26) = D4 (0) C5 (27) = C4 (1) D5 (27) = D4 ( 1) 'Combination C5, D5 into c_d for i =

0 to 27 c_d (i) = C5 (i) C_D (i 28) = D5 (i) Next 'PC_2 conversion, generate K5 for i = 0 to 47 k5 (i) = C_D (PC_2 (I)) NEXT' *********************************************************** * K6 'generates C6, D6 FOR i = 0 to 25 C6 (i) = C5 (i LSI (6)) D6 (i) = D5 (i LSI (6)) Next C6 (26) = C5 (0 ) D6 (26) = D5 (0) C6 (27) = C5 (1) D6 (27) = D5 (1) 'combination C6, D6 is c_d for i = 0 to 27 c_d (i) = c6 (i) C_D (i 28) = D6 (i) Next 'PC_2 conversion, generate K6 for i = 0 to 47 k6 (i) = c_d (pc_2 (i)) Next' ************ ************************************** K7 'to generate C7, D7 for i = 0 to 25 C7 (I) = C6 (i LSI (7)) D7 (i) = D6 (i LSI (7)) Next C7 (26) = C6 (0) D7 (26) = D6 (0) C7 ( 27) = C6 (1) D7 (27) = D6 (1) 'combination C7, D7 C_D for i = 0 to 27 c_d (i) = C7 (I) C_D (i 28) = D7 (i) Next 'PC_2 conversion, generate K7 for i = 0 to 47 k7 (i) = c_d (pc_2 (i)) Next' *********************** ******************* ******* K8 'Generates C8, D8 for i = 0 to 25 c8 (i) = C7 (i LSI (8)) D8 (i) = D7 (i LSI (8)) Next C8 ( 26) = C7 (0) D8 (26) = D7 (0) C8 (27) = C7 (1) D8 (27) = D7 (1) 'combination C8, D8 into c_d for i = 0 to 27 c_d (i ) = C8 (i) c_d (i) NEXT 'PC_2 conversion, generate K8 for i = 0 to 47 k8 (i) = C_D (PC_2 (I)) Next' ****** ******************************************** K9 'to generate C9, D9 for i = 0 to 26 c9 (i) = c8 (i

LSI (9)) D9 (i) = D8 (i LSI (9)) Next C9 (27) = C8 (0) D9 (27) = D8 (0) 'combination C9, D9 into c_d for i = 0 TO 27 c_d (i) = c9 (i) C_D (i 28) = D9 (i) Next 'PC_2 conversion, generate K9 for i = 0 to 47 k9 (i) = C_D (PC_2 (I)) Next' ** ******************************************************************** K10 'Generate C10, D10 for i = 0 to 25 C10 (i) = C9 (i LSI (10)) D10 (i) = D9 (i LSI (10)) Next C10 (26) = C9 (0) D10 (26) = D9 (0) C10 (27) = C9 (1) D10 (27) = D9 (1) 'combination C10, D10 is c_d for i = 0 to 27 c_d (i) = C10 (i) C_D ( i 28) = D10 (i) Next 'PC_2 conversion, generate K10 for i = 0 to 47 k10 (i) = c_d (pc_2 (i)) Next' ************* ************************************ K11 'to generate C11, D11 for i = 0 to 25 C11 (i) = C10 (i lsi (11)) D11 (i) = d10 (i lsi (11)) Next C11 (26) = C10 (0) D11 (26) = D10 (0) C11 (27) = C10 (1) D11 (27) = D10 (1) 'combination C11, D11 is C_D FOR i = 0 to 27 c_d (i) = C11 (i) C_D (I 28) = D11 (i) Next 'PC_2 conversion, generate K11 for i = 0 to 47 k11 (i) = c_d (PC_2 (I)) Next' ************** ************************************ K12 'to generate C12, D12 for i = 0 to 25 C12 ( I) = C11 (i lsi (12)) D12 (i) = D11 (i LSI (12)) Next C12 (26) = C11 (0) D12 (26) = D11 (0) C12 (27) = C11 (1) D12 (27) = D11 (1) 'combination C12, D12 is c_d for i = 0 to 27 c_d (i) = C12 (I) C_D (i 28) = D12 (i) Next'

PC_2 conversion, generating K12 for i = 0 to 47 k12 (i) = C_D (PC_2 (I)) Next '************************ ************************** K13 'to generate C13, D13 for i = 0 to 25 C13 (i) = C12 (i lsi (13 )) D13 (i) = D12 (i lsi (13)) Next C13 (26) = C12 (0) D13 (26) = D12 (0) C13 (27) = C12 (1) D13 (27) = D12 (1) 'Combination C13, D13 into c_d for i = 0 to 27 c_d (i) = C13 (i) c_d (i 28) = D13 (i) Next' PC_2 conversion, generate K13 for i = 0 to 47 k13 (i) = c_d (PC_2 (I)) Next '******************************************** ************** K14 'Generate C14, D14 for i = 0 to 25 C14 (I) = C13 (i LSI (14)) D14 (I) = D13 (i LSI (14)) NEXT C14 (26) = C13 (0) D14 (26) = D13 (0) C14 (27) = C13 (1) D14 (27) = D13 (1) 'combination C14, D14 C_D for i = 0 to 27 c_d (i) = C14 (i) C_D (i) = D14 (i) Next 'PC_2 conversion, generate K14 for i = 0 to 47 k14 (i) = c_d (PC_2 (I)) Next '********************************************************** ** K15 'Generate C15, D15 FOR i = 0 to 25 C15 (i) = C14 (i LSI (15)) D15 (i) = D14 (i LSI (15)) Next C15 (26) = C14 (0) D15 (26) = D14 (0) C15 (27) = C14 (1) D15 (27) = D14 (1) 'combination C15, D15 C_D for i = 0 to 27 c_d (i) = C15 (I) C_D (i 28) = D15 (i) Next 'PC_2 conversion, generate K15 FOR i = 0 to 47 k15 (i) = C_D (PC_2 (I)) Next' ****************** ******************************** K16 'to generate C16, D16 for i = 0 to 26 C16 (i) = C15 (i

LSI (16)) D16 (i) = D15 (i LSI (16)) Next C16 (27) = C15 (0) D16 (27) = D15 (0) combination C16, D16 C_D for i = 0 TO 27 c_d (i) = C16 (i) C_D (i 28) = D16 (i) Next 'PC_2 conversion, generate K16 FOR i = 0 to 47 k16 (i) = C_D (PC_2 (I)) Next' ** *********************************************************** *********************************** The "encryption process" extends the number of molar digits to 8 multiples IF (Ubound) (scode) 1) MOD 8> 0 THEN Redim Preserve Scode ((Ubound (Scode) 1) / 8 1) * 8 - 1) 'Define Return Cipheet Length Redim Breturn (Ubound (Scode))

For J = 0 to Ubound (scode) Step 8 CopyMemory Tempcode (0), Scode (j), 8 for i = 0 to 7 bincode (i * 8 0) = (Tempcode (i) and & h80) / & h80 bincode i * 8 1) = (Tempcode (i) and & h40) / & H40 bincode (i * 8 2) = (Tempcode (i) and & H20) / & H20 bincode (i * 8 3) = (Tempcode (i) And & H10) / & H10 bincode (i * 8 4) = (Tempcode (i) and & h8) / & H8 bincode (i * 8 5) = (Tempcode (i) and & h4) / & h4 bincode (i * 8 6 ) = (Tempcode (i) and & h2) / & H2 bincode (i * 8 7) = (Tempcode (i) and & h1) / & H1 next 'ip replacement for i = 0 to 63 codeip (i) = bincode (IP (IP) I)) NEXT 'segmentation for i = 0 to 31 r0 (i) = Codeip (i) L0 (i) = Codeip (i 32) Next' for the first time iterative for i = 0 to 47 codee (i) = R0 (e (i)) 'After e-conversion expansion, the 32-bit becomes 48 code (i) = Codee (i) XOR K16 (i)' and K16 pressing does not carry the addition operation next 'points 8 groups For i = 0 to 5 CODES1 (i) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = COD EE (I 12) CODES4 (I) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = codee (i 36) CODES8 (I) = CODEE (i 42) Next 'S box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) s (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2 ) * 4 CODES2 (1) * 8) s (2) =

S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) ) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0 * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (i) and & h2) / & H2 rets (i * 4 3) = (s (i) and & H1) / & H1 next for i = 0 to 31 'P Transform CODEP (i) = RETS (p (i))' Generate L1, R1 R1 (I) = L0 (I) XOR CODEP (I) L1 (i) = R0 (i) Next ' Row second iteration for i = 0 to 47 CODEE (i) = r1 (e (i)) 'After e-conversion expansion, the 32-bit becomes 48-bit Codee (i) = Codee (i) xor k15 (i) 'And K15 pressing does not carry the addition of the operation next' points 8 group for i = 0 to 5 CODES1 (i) = codeE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = codee (i 12) CODES4 (I) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = Codee (i 36) CODES8 (i) =

CODEE (i 42) Next 'S box calculation, get 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2 * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8 S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) S (6) = S7 (CODES7 (5) CODES7 ( 0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) s (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) And & H8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 RETS (i * 4 2) = (s (i) and & h2) / & H2 rets (i * 4 3) = (s (i) and & h1) / & h1 next for i = 0 to 31 'P conversion CODEP I) = RETS (p (i)) 'generates L2, R2 R2 (I) = L1 (i) xor CODEP (i) L2 (I) = R1 (i) Next' to perform the third iterative for i = 0 TO 47 CODEE (I) = R2 (e (i)) 'After e-conversion, the 32-bit becomes 48 code (i) = Codee (i) xor k14 (i)' and K14 bits do not enter the addition Next 'points 8 group for i =

0 TO 5 CODES1 (I) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = CODEE (i 12) CODES4 (i) = Codee (i 18) CODES5 (i) = CODEE (i) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 'S box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) s (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 ( 4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, Codes6 (4) CODES6 ( 3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & h8 rets (i * 4 1) = (s (i) and & H4) / & H4 RETS (i * 4 2) = (S (i) and & h2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & h1 next for i = 0 to 31 ' P conversion CODEP (i) =

RETS (p (i)) 'produces L3, R3 R3 (I) = L2 (i) XOR CODEP (I) L3 (i) = R2 (I) Next' to perform the fourth iterative for i = 0 to 47 CODEE I) = R3 (e (i)) 'After e-conversion expansion, the 32-bit becomes 48-bit codee (i) = CODEE (i) XOR K13 (i)' and K13 bit position does not carry the addition of the addition of the NEXT ' 8 group for i = 0 to 5 CODES1 (i) = codee (i) CODES2 (i) = codee (i 6) CODES3 (i) = codee (i 12) CODES4 (i) = codee (i 18) CODES5 (I) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = Codee (i 42) Next 'S box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 Codes4 (1) * 8) S (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) ) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0 * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i =

0 TO 7 RETS (i * 4 0) = (S (i) and & H8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (S (i) and & h2) / & H2 RETS (i * 4 3) = (S (i) and & h1) / & H1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i) ) 'Generate L4, R4 R4 (I) = L3 (i) XOR CODEP (i) L4 (i) = R3 (i) NEXT' Performing the fifth iterative for i = 0 to 47 CODEE (I) = R4 (e (i)) 'After e-conversion, it becomes 48-bit Codee (i) = CodeE (i) xor k12 (i)' and K12 bits, 8 sets for i = 0 To 5 CODES1 (I) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = CODEE (i 12) CODES4 (i) = CODEE (i 18) CODES5 (i) = Codee (i 24) CODES6 (i) = CODEE (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 'S box calculation, 8 numbers S ( 0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 ( CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, Codes4 (4) CODES4 (3) * 2 CODES4 ( 2) * 4 CODES4 (1) * 8) S (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2

CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1 ) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (S (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) And & H4) / & H4 RETS (i * 4 2) = (S (i) and & H2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & h1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i)) "Generates L5, R5 R5 (I) = L4 (i) XOR CODEP (i) L5 (I) = R4 (I) Next' to perform the sixth iteration For i = 0 to 47 CODEE (I) = R5 (e (i)) 'After e-conversion expansion, the 32-bit becomes 48-bit Codee (I) = Codee (i) XOR K11 (i)' and K11 Do not carry the addition of the addition of the NEXT '分 8 group for i = 0 to 5 CODES1 (i) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = CODEE (i 12) CODES4 (i ) = CODEE (i 18) CODES5 (i) = codee (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 'S box calculation, get 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 ( 4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) s (3) =

S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) ) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0 ) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) s (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 rets (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (i) and & h2) / & H2 rets (i * 4 3) = ( S (i) and & h1) / & h1 next for i = 0 to 31 'p conversion CODEP (i) = RETS (p (i))' generates L6, R6 R6 (I) = L5 (i) xor CODEP (i) L6 (i) = r5 (i) Next 'performs the seventh iterative for i = 0 to 47 codee (i) = R6 (e (i))' E-converted, from 32-bit to 48-bit CODE E (i) = codee (i) xor k10 (i) 'and K10 bit by position does not carry the addition of NEXT' 分 8 group for i = 0 to 5 CODES1 (i) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = CODEE (i 12) CODES4 (i) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = codee (i 30) CODES7 (i) = CODEE (i) = CODEE (i 42) Next 'S box calculation, get 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4)

CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2 ) * 4 CODES3 (1) * 8) s (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 Codes4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8 ) S (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) S (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) s (7) = S8 (CODES8 ( 5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S Box Operation 32 Results for i = 0 TO 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (i) ) And & h2) / & H2 rets (i * 4 3) = (s (i) and & h1) / & h1 next FOR i = 0 to 31 'P conversion CODEP (i) = RETS (p (i))' generates L7, R7 R7 (I) = L6 (i) xor CODEP (i) L7 (I) = R6 (i) Next 'Performing the eighth iterative for i = 0 to 47 CODEE (i) = R7 (e (i))' After e-conversion expansion, the 32-bit becomes 48-bit Codee (i) = Codee (i) xor k9 (i ) 'And K9 pressing does not carry the addition of NEXT' score 8 group for i = 0 to 5 CODES1 (i) = Codee (i) CODES2 (i) = Codee (i 6) CODES3 (i) = codee (i

12) CODES4 (I) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = Codee (i 36) CODES8 (i) = CODEE (i 42) Next 'S box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 ( 2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 Codes3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4 ) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) S (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2 , CODES8 (4) CODES8 (3) * 2 CODES8 ( 2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & h8 rets (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (S (i) and & h2) / & H2 rets (i * 4 3) = (s (i) and & h1) / & H1 next for i = 0 to 31 'P Transform CODEP (i) = RETS (p (i))' Generate L8, R8 R8 (I) = L7 (I) XOR CODEP (I) L8 (I) = R7 (i NEXT '

Performing the 9th iteration for i = 0 to 47 CODEE (I) = R8 (e (i)) 'After e-conversion expansion, the 32-bit becomes 48-bit Codee (I) = Codee (i) xor k8 (i) 'And K8 bits do not carry the addition of the calculation NEXT' 分 8 group for i = 0 to 5 CODES1 (i) = codeE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = codee (i 12) CODES4 (I) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = Codee (i 36) CODES8 (i) = CODEE (i 42) Next 'S box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 ( 2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 Codes3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4 ) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) ) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box operation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / &

H4 RETS (i * 4 2) = (s (i) and & h2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & H1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i)) 'produces L9, R9 R9 (I) = L8 (i) XOR CODEP (i) L9 ​​(i) = r8 (i) Next' to perform the 10th iteration for i = 0 TO 47 CODEE (I) = R9 (e (i)) 'After e-conversion, it becomes 48-bit Codee (i) = Codee (i) xor k7 (i)' and K7 bit by 32 bits. Computing Next 'points 8 group for i = 0 to 5 CODES1 (i) = codeE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = Codee (i 12) Codes4 (i) = codee i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = codee (i 36) CODES8 (i) = Codee (i 42) Next ' S-box operation, get 8 numbers s (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) s (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S ( 2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, Codes4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2 * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2

CODES7 (2) * 4 CODES7 (1) * 8) s (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (S (i) and & h8) / & H8 rets (i * 4 1) = (S (i) and & h4) / & H4 RETS (i * 4 2) = (S (i) and & H2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & H1 Next for I = 0 to 31 'P Transform CODEP (I) = RETS (p (i))' Generate L10, R10 R10 (I) = L9 (i) XOR CODEP (I) L10 (I) = R9 (I) Next ' Performing the 11th iteration for i = 0 to 47 CODEE (I) = R10 (e (i)) 'E-expanded, becoming 48-bit Codee (i) = Codee (i) xor k6 (i) = CODEE (i) xor k6 (i) 'And K6 Bouting Corporation NEXT' 分 8 Groups for i = 0 to 5 CODES1 (i) = CODEE (i) CODES2 (i) = CODEE (i 6) CODES3 (i) = Codee (i 12) CODES4 (I) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = CODEE (i 30) CODES7 (i) = Codee (i 36) CODES8 (i) = CODEE (i 42) Next 's Box operation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) s (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2 ) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) s (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4

CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) S (6 = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) s (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S Box Operation 32 Result for i = 0 TO 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (s) I) AND & H2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & H1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i))' generation L11, R11 R11 (I) = L10 (i) XOR CODEP (I) L11 (I) = R10 (i) Next 'Performing the 12th iterative for i = 0 to 47 CODEE (I) = R11 (e (i) ) 'After e-conversion, it becomes 48-bit code (i) = code (i) xor k5 (i)' and K5 bit by bit (i) = Codee (i) XOR K5 (i) ' For i = 0 to 5 CODES1 (i) = CODEE (i) CODES2 (i) = CODEE (i) = Codee (i 12) CODES4 (i) = Codee (i 18) Codes5 ( I) = CODEE (i) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 's box operation, get 8 Number S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1 ) = S2 (CODES2 (5)

CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) Codes4 (0) * 2, CODES4 (4 ) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3 * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & h8 rets (i * 4 1) = (s (i) and & H4) / & H4 RETS (i * 4 2) = (S (i) and & h2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & h1 next for i = 0 to 31 ' P conversion CODEP (i) = RETS (p (i)) 'Generate L12, R12 R12 (I) = L11 (i) XOR CODEP (I) L12 (I) = R11 (I) NEXT' Performing the 13th Ieration for i = 0 to 47 CODEE (I) = R12 (E (E) I)) 'After e-conversion expansion, the 32-bit becomes 48 code (i) = code (i) xor k4 (i)' and K4 bit by position, no carry-on operation Next 'points 8 group for i = 0 TO 5 CODES1 (I) = CODEE (i) CODES2 (I) = CODEE (i 6) CODES3 (i) = CODEE (i 12) CODES4 (i) = CODEE (i 18) Codes5 (i) = Codee i

24) CODES6 (i) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 'S box calculation, 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) ) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2) = S3 (CODES3 (5) CODES3 (0 * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) s (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 ( 1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 RETS (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (s) I) AND & H2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & H1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i))' generation L13, R13 R13 (I) = L12 (i) XOR CODEP (I) L13 (i) = R12 (i) Next 'performs the fourth iteration for i = 0 to 47 CODEE (I) = R13 (E (i) ) '

After e-conversion expansion, the 32-bit becomes 48-bit Codee (i) = code (i) xor k3 (i) 'with K3 bit by position, non-carrying operation next' points 8 group for i = 0 to 5 CODES1 (i ) = CODEE (i) CODES2 (i) = codee (i 6) CODES3 (i) = codee (i 12) CODES4 (i) = codee (i 18) CODES5 (i) = codee (i 24) CODES6 (I) = CODEE (i 30) CODES7 (i) = CODEE (i 36) CODES8 (i) = CODEE (i 42) Next 'S box operation, 8 numbers S (0) = S1 ( CODES1 (5) CODES1 (0) * 2, CODES1 (4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) S (3) = S4 (CODES4 (5) Codes4 (0) * 2, CODES4 (4 ) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) s (4) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3 * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) S (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 ( 1) * 8) s (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 RETS (i * 4 0) = (S (i) and & h8) / & H8 RETS (i * 4 1) = (S (i) and & h4) / & H4 rets (i * 4 2) = (s (i) and & h2) / & h2 rets (i * 4 3) =

(S (i) and & h1) / & h1 next for i = 0 to 31 'P conversion CODEP (i) = RETS (p (i))' Generate L14, R14 R14 (I) = L13 (i) XOR CODEP (i ) L14 (I) = R13 (i) Next 'Performs the 15th iteration for i = 0 to 47 CODEE (i) = R14 (e (i))' After e-conversion, the 32-bit becomes 48 codee ( I) = CODEE (i) xor k2 (i) 'and K2 bit by position does not carry the addition operation next' points 8 group for i = 0 to 5 CODES1 (i) = codeE (i) CODES2 (i) = Codee (i 6) CODES3 (I) = CODEE (i 12) CODES4 (i) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = Codee (i 30) CODES7 (i ) = CODEE (i) = CODEE (i 42) Next 'S box calculation, get 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 ( 4) CODES1 (3) * 2 CODES1 (2) * 4 CODES1 (1) * 8) s (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 ( 3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) S (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 CODES3 (1) * 8) s (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4) = S5 (CODES5 ( 5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4 CODES5 (1) * 8) S (5) = S6 (CODES6 (5) CODES6 ( 0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 CODES6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4)

CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box calculation 32-bit results for i = 0 to 7 retrs (i * 4 0) = (s (i) and & h8 ) / & H8 rets (i * 4 1) = (s (i) and & h4) / & H4 rets (i * 4 2) = (s (i) and & h2) / & H2 rets (i * 4 3) = (S (i) and & h1) / & h1 next for i = 0 to 31 'p conversion CODEP (i) = RETS (p (i))' Generate L15, R15 R15 (I) = L14 (i) XOR CODEP (I ) L15 (I) = R14 (i) Next 'Performs the 16th iteration for i = 0 to 47 CODEE (I) = R15 (e (i))' After e-conversion expansion, the 32-bit becomes 48 codee ( I) = CODEE (i) xor k1 (i) 'and K1 bit by bit do not carry the addition of the complex operation next' points 8 group for i = 0 to 5 CODES1 (i) = Codee (i) Codes2 (i) = codee (i 6) CODES3 (I) = CODEE (i 12) CODES4 (i) = CODEE (i 18) CODES5 (i) = CODEE (i 24) CODES6 (i) = Codee (i 30) CODES7 (i ) = CODEE (i) = CODEE (i 42) Next 'S box calculation, get 8 numbers S (0) = S1 (CODES1 (5) CODES1 (0) * 2, CODES1 ( 4) CODES1 (3) * 2 CODES1 ( 2) * 4 CODES1 (1) * 8) S (1) = S2 (CODES2 (5) CODES2 (0) * 2, CODES2 (4) CODES2 (3) * 2 CODES2 (2) * 4 CODES2 (1) * 8) s (2) = S3 (CODES3 (5) CODES3 (0) * 2, CODES3 (4) CODES3 (3) * 2 CODES3 (2) * 4 Codes3 (1) * 8) S (3) = S4 (CODES4 (5) CODES4 (0) * 2, CODES4 (4) CODES4 (3) * 2 CODES4 (2) * 4 CODES4 (1) * 8) S (4 ) = S5 (CODES5 (5) CODES5 (0) * 2, CODES5 (4) CODES5 (3) * 2 CODES5 (2) * 4

CODES5 (1) * 8) s (5) = S6 (CODES6 (5) CODES6 (0) * 2, CODES6 (4) CODES6 (3) * 2 CODES6 (2) * 4 Codes6 (1) * 8) s (6) = S7 (CODES7 (5) CODES7 (0) * 2, CODES7 (4) CODES7 (3) * 2 CODES7 (2) * 4 CODES7 (1) * 8) S (7 ) = S8 (CODES8 (5) CODES8 (0) * 2, CODES8 (4) CODES8 (3) * 2 CODES8 (2) * 4 CODES8 (1) * 8) 'S box operation 32-bit results for For i = 0 to 7 RETS (i * 4 0) = (s (i) and & h8) / & H8 rets (i * 4 1) = (s (i) and & h4) / & h4 rets (i * 4 2 ) = (S (i) and & h2) / & H2 RETS (i * 4 3) = (s (i) and & h1) / & H1 next for i = 0 to 31 'p conversion CODEP (i) = RETS (p (p) I))) 'Generate L11, R11 R16 (I) = L15 (i) xor CODEP (i) L16 (i) = R15 (i) Next for i = 0 to 31 bincode (i) = R16 (I) Bincode (I 32) = L16 (i) Next for i = 0 to 63 codeip (i) = bincode (ip_1 (i)) Next for i = 0 to 7 Tempreturn (i) = codeip (i * 8 0) * & H80 Tempreturn (i) = Tempreturn (i) Codeip (i * 8 1) * & H40 Tempreturn (i) = Tempreturn (i) Codeip (i * 8 2) * & H20 Tempreturn (i) = Tempreturn (i) Codeip (i * 8 3) * & H10 Tempreturn (i) = Tempreturn (i) Codeip (i * 8 4) * & H8 Tempreturn (i) = Tempreturn (i) Codeip (i * 8 5) * & H4 Tempreturn (i) = Tempreturn (i) CodeIP (i * 8 6) * & H2 Tempreturn (I) = Tempreturn (i) Codeip (i * 8 7) * & H1 NextCopyMemory Breturn (J), Tempreturn (0), 8Next

End Sub has given this article to give me a brother who is struggling in VB like me !!

转载请注明原文地址:https://www.9cbs.com/read-28127.html

New Post(0)