用VB实现DES加解密算法(一)
2008-02-23 06:49:19来源:互联网 阅读 ()
用VB实现DES加解密算法(一)
用VB实现DES加解密算法(一)--定义
'DES加解密算法实现 vb版 v1.0
'
'作者: 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 ' 23
IP(62) = 14 ' 15
IP(63) = 6 ' 7
IP_1(0) = 39 ' 40
IP_1(1) = 7 ' 8
IP_1(2) = 47 ' 48
IP_1(3) = 15 ' 16
IP_1(4) = 55 ' 56
IP_1(5) = 23 ' 24
IP_1(6) = 63 ' 64
IP_1(7) = 31 ' 32
IP_1(8) = 38 ' 39
IP_1(9) = 6 ' 7
IP_1(10) = 46 ' 47
IP_1(11) = 14 ' 15
IP_1(12) = 54 ' 55
IP_1(13) = 22 ' 23
IP_1(14) = 62 ' 63
IP_1(15) = 30 ' 31
IP_1(16) = 37 ' 38
IP_1(17) = 5 ' 6
IP_1(18) = 45 ' 46
IP_1(19) = 13 ' 14
IP_1(20) = 53 ' 54
IP_1(21) = 21 ' 22
IP_1(22) = 61 ' 62
IP_1(23) = 29 ' 30
IP_1(24) = 36 ' 37
IP_1(25) = 4 ' 5
IP_1(26) = 44 ' 45
IP_1(27) = 12 ' 13
IP_1(28) = 52 ' 53
IP_1(29) = 20 ' 21
IP_1(30) = 60 ' 61
IP_1(31) = 28 ' 29
IP_1(32) = 35 ' 36
IP_1(33) = 3 ' 4
IP_1(34) = 43 ' 44
IP_1(35) = 11 ' 12
IP_1(36) = 51 ' 52
IP_1(37) = 19 ' 20
IP_1(38) = 59 ' 60
IP_1(39) = 27 ' 28
IP_1(40) = 34 ' 35
IP_1(41) = 2 ' 3
IP_1(42) = 42 ' 43
IP_1(43) = 10 ' 11
IP_1(44) = 50 ' 51
IP_1(45) = 18 ' 19
IP_1(46) = 58 ' 59
IP_1(47) = 26 ' 27
IP_1(48) = 33 ' 34
IP_1(49) = 1 ' 2
IP_1(50) = 41 ' 42
IP_1(51) = 9 ' 10
IP_1(52) = 49 ' 50
IP_1(53) = 17 ' 18
IP_1(54) = 57 ' 58
IP_1(55) = 25 ' 26
IP_1(56) = 32 ' 33
IP_1(57) = 0 ' 1
IP_1(58) = 40 ' 41
IP_1(59) = 8 ' 9
IP_1(60) = 48 ' 49
IP_1(61) = 16 ' 17
IP_1(62) = 56 ' 57
IP_1(63) = 24 ' 25
E(0) = 31
For i = 1 To 5
E(i) = i - 1
Next
For i = 6 To 11
E(i) = i - 3
Next
For i = 12 To 17
E(i) = i - 5
Next
For i = 18 To 23
E(i) = i - 7
Next
For i = 24 To 29
E(i) = i - 9
Next
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:获得主机的IP地址
下一篇:用VB打造自己的SQL连接器
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash