文档介绍:用VB实现DES加解密算法
无忧IT网- 软件开发( 日期:2005-8-11)
1 2 3 下一页
(一)--定义
''DES加解密算法实现 vb版
''
''作者: agamem
''日期: 2003年08月27日
''
''
''
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
''置换表
Private IP(63) As Byte ''IP置换码
Private IP_1(63) As Byte ''IP-1置换码
Private E(47) As Byte ''E膨胀码
Private P(31) As Byte ''P变换码
Private S1(3, 15) As Byte ''S盒1
Private S2(3, 15) As Byte ''S盒2
Private S3(3, 15) As Byte ''S盒3
Private S4(3, 15) As Byte ''S盒4
Private S5(3, 15) As Byte ''S盒5
Private S6(3, 15) As Byte ''S盒6
Private S7(3, 15) As Byte ''S盒7
Private S8(3, 15) As Byte ''S盒8
Private PC_1(55) As Byte
Private PC_2(47) As Byte
Private Lsi(16) As Byte ''循环左移位
Private Sub Class_Initialize()
Dim i As Integer
IP(0) = 57 '' 58
IP(1) = 49 '' 50
IP(2) = 41 '' 42
IP(3) = 33 '' 34
IP(4) = 25 '' 26
IP(5) = 17 '' 18
IP(6) = 9 '' 10
IP(7) = 1 '' 2
IP(8) = 59 '' 60
IP(9) = 51 '' 52
IP(10) = 43 '' 44
IP(11) = 35 '' 36
IP(12) = 27 '' 28
IP(13) = 19 '' 20
IP(14) = 11 '' 12
IP(15) = 3 '' 4
IP(16) = 61 '' 62
IP(17) = 53 '' 54
IP(18) = 45 '' 46
IP(19) = 37 '' 38
IP(20) = 29 '' 30
IP(21) = 21 '' 22
IP(22) = 13 '' 14
IP(23) = 5 '' 6
IP(24) = 63 '' 64
IP(25) = 55 '' 56
IP(26) = 47 '' 48
IP(27) = 39 '' 40
IP(28) = 31 '' 32
IP(29) = 23 '' 24
IP(30) = 15 '' 16
IP(31) = 7 '' 8
IP(32) = 56 '' 57
IP(33) = 48 '' 49
IP(34) = 40 '' 41
IP(35) = 32 '' 33
IP(36) = 24 '' 25
IP(37) = 16 '' 17
IP(38) = 8 '' 9
IP(39) = 0 '' 1
IP(40) = 58 '' 59
IP(41) = 50 '' 51
IP(42) = 42 '' 43
IP(43) = 34 '' 35
IP(44) = 26 '' 27
IP(45) = 18 '' 19
IP(46) = 10 '' 11
IP(47) = 2 '' 3
IP(48) = 60 '' 61
IP(49) = 52 '' 53
IP(50) = 44 '' 45
IP(51) = 36 '' 37
IP(52) = 28 '' 29
IP(53) = 20 '' 21
IP(54) = 12 '' 13
IP(55) = 4 '' 5
IP(56) = 62 '' 63
IP(57) = 54 '' 55
IP(58) = 46 '' 47
IP(59) = 38 '' 39
IP(60) = 30 '' 31
IP(61) = 22 ''