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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L3,R3
R3(i) = L2(i) Xor CodeP(i)
L3(i) = R2(i)
Next
'进行第四次迭代
For i = 0 To 47
CodeE(i) = R3(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K13(i) '与K13按位作不进位加法运算
Next
'分8组
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盒运算,得到8个数
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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L4,R4
R4(i) = L3(i) Xor CodeP(i)
L4(i) = R3(i)
Next
'进行第五次迭代
For i = 0 To 47
CodeE(i) = R4(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K12(i) '与K12按位作不进位加法运算
Next
'分8组
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盒运算,得到8个数
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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L5,R5
R5(i) = L4(i) Xor CodeP(i)
L5(i) = R4(i)
Next
'进行第六次迭代
For i = 0 To 47
CodeE(i) = R5(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K11(i) '与K11按位作不进位加法运算
Next
'分8组
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盒运算,得到8个数
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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L6,R6
R6(i) = L5(i) Xor CodeP(i)
L6(i) = R5(i)
Next
'进行第7次迭代
For i = 0 To 47
CodeE(i) = R6(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K10(i) '与K10按位作不进位加法运算
Next
'分8组
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盒运算,得到8个数
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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L7,R7
R7(i) = L6(i) Xor CodeP(i)
L7(i) = R6(i)
Next
'进行第8次迭代
For i = 0 To 47
CodeE(i) = R7(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K9(i) '与K9按位作不进位加法运算
Next
'分8组
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盒运算,得到8个数
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盒运算32位结果
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变换
CodeP(i) = RetS(P(i))
'产生L8,R8
R8(i) = L7(i) Xor CodeP(i)
L8(i) = R7(i)
Next
'进行第9次迭代
For i = 0 To 47
CodeE(i) = R8(E(i)) '经过E变换扩充,由32位变为48位
CodeE(i) = CodeE(i) Xor K8(i) '与K8按位作不进位加法运算
Next
'分8组
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
全国最大的 Java专业电子书免费分享[url]http:///in.asp?id=xrmao[/url]