简单文件加解密_异惑法
加解密.vbpType=Exe
Form=Form1.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX
Startup="Form1"
Command32=""
Name="工程1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="微软中国"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1
---------------------------------
Form1.frm
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "文件加解密"
ClientHeight = 2025
ClientLeft = 60
ClientTop = 450
ClientWidth = 7125
LinkTopic = "Form1"
ScaleHeight = 2025
ScaleWidth = 7125
StartUpPosition = 3 '窗口缺省
Begin CommonD1
Left = 5640
Top = 1200
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin Command3
Caption = "..."
Height = 375
Left = 6600
TabIndex = 9
Top = 600
Width = 495
End
Begin Command2
Caption = "..."
Height = 375
Left = 6600
TabIndex = 8
Top = 120
Width = 495
End
Begin VB.TextBox PassW
Height = 375
IMEMode = 3 'DISABLE
Left = 960
PasswordChar = "*"
TabIndex = 7
Top = 1080
Width = 2055
End
Begin VB.TextBox NewFile
Height = 375
Left = 960
TabIndex = 5
Top = 600
Width = 5535
End
Begin VB.TextBox OldFile
Height = 375
Left = 960
TabIndex = 3
Top = 120
Width = 5535
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 255
Left = 0
TabIndex = 1
Top = 1680
Width = 7095
_ExtentX = 12515
_ExtentY = 450
_Version = 393216
Appearance = 1
End
Begin Command1
Caption = "加/解密文件"
Height = 495
Left = 3240
TabIndex = 0
Top = 1080
Width = 1455
End
Begin VB.Label Label3
Caption = "密码:"
Height = 255
Left = 360
TabIndex = 6
Top = 1200
Width = 495
End
Begin VB.Label Label2
Caption = "新文件:"
Height = 375
Left = 240
TabIndex = 4
Top = 720
Width = 735
End
Begin VB.Label Label1
Caption = "源文件:"
Height = 255
Left = 240
TabIndex = 2
Top = 240
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim B() As Byte
Dim PassWord As String
Dim B1() As Byte
Dim I As Long, l As Long, j As Long
Private Sub Command1_Click()
Open OldFile For Binary As #1
If LOF(1) > 0 Then
j = LOF(1)
ReDim B(LOF(1) - 1)
Get #1, , B
End If
Close #1
Dim P As Long
PassWord = PassW
l = Len(PassWord)
ReDim B1(l)
For I = 1 To l
B1(I) = Asc(Mid(PassWord, I, 1))
Next
'ProgressBar1.Max = UBound(B)
For I = 0 To UBound(B)
B(I) = B(I) Xor B1(P)
P = P + 1
'ProgressBar1.Value = I
If P > l Then P = 0
Next
Open NewFile For Binary As #1
Put #1, , B
Close #1
'ProgressBar1.Value = 0
End Sub
Private Sub Command2_Click()
CommonD1.FileName = ""
CommonD1.ShowOpen
If CommonD1.FileName = "" Then Exit Sub
OldFile = CommonD1.FileName
End Sub
Private Sub Command3_Click()
CommonD1.FileName = ""
CommonD1.ShowSave
If CommonD1.FileName = "" Then Exit Sub
NewFile = CommonD1.FileName
End Sub