-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmMain.frm
214 lines (200 loc) · 6.92 KB
/
frmMain.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "Encrypt/Decrypt Tool"
ClientHeight = 2010
ClientLeft = 45
ClientTop = 435
ClientWidth = 6360
BeginProperty Font
Name = "Verdana"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2010
ScaleWidth = 6360
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox txtPass
Height = 315
Left = 1320
TabIndex = 4
Top = 960
Width = 4935
End
Begin VB.CommandButton cmdCom
Caption = "OK"
Height = 375
Left = 4920
TabIndex = 3
Top = 1320
Width = 1335
End
Begin VB.TextBox txtPath
Height = 315
Left = 1200
OLEDropMode = 1 'Manual
TabIndex = 1
Top = 480
Width = 5055
End
Begin VB.Label lblSta
BackStyle = 0 'Transparent
Height = 255
Left = 1440
TabIndex = 7
Top = 1440
Width = 3135
End
Begin VB.Label lblAuthor
BackStyle = 0 'Transparent
Caption = "Copyright © Free for All"
BeginProperty Font
Name = "Verdana"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2280
TabIndex = 6
Top = 1800
Width = 2175
End
Begin VB.Label lblPass
BackStyle = 0 'Transparent
Caption = "Password:"
Height = 255
Left = 120
TabIndex = 5
Top = 1080
Width = 1095
End
Begin VB.Label lblPath
BackStyle = 0 'Transparent
Caption = "File Path:"
Height = 255
Left = 120
TabIndex = 2
Top = 600
Width = 1215
End
Begin VB.Label lbl1
BackStyle = 0 'Transparent
Caption = "Drop your file into the ""File Path"" box to begin"
BeginProperty Font
Name = "Verdana"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 720
TabIndex = 0
Top = 120
Width = 5415
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private EncryptCryptAPI As clsCryptAPI
Private Sub cmdCom_Click()
'Complete : 0h15 26/11/2008 :)
'On Error Resume Next
If txtPass.Text = "" Then
MsgBox "Password is required!"
Else
'Xu ly du lieu
If FileExist(txtPath.Text) = True Then
Dim buff As String
Dim strMD5 As String
buff = InputFile(txtPath)
Dim strR As String
strR = EncryptCryptAPI.DecryptString(Left(buff, 6), "dark")
If strR <> "eNcOdE" Then
'Neu du lieu chua duoc
strMD5 = MD5String(buff)
'buff = EncryptString(buff, txtPass.Text)
'Cau truc
'eNCoDe strMD5 Data
buff = EncryptCryptAPI.EncryptString("eNcOdE", "dark") & _
EncryptCryptAPI.EncryptString(strMD5, "light" & CStr(Len(buff))) & _
EncryptCryptAPI.EncryptString(buff, txtPass.Text)
CreatAFile buff, txtPath & ".encrypted"
MsgBox "Successfully! File has been encrypted with the extension (.encrypted)."
Else
'Neu du lieu da duoc ma hoa
Dim lgLen As Long
lgLen = Len(buff) - 38
strMD5 = Mid(buff, 7, 32)
strMD5 = EncryptCryptAPI.DecryptString(strMD5, "light" & CStr(lgLen))
buff = Right(buff, Len(buff) - 38)
buff = EncryptCryptAPI.DecryptString(buff, txtPass.Text)
If strMD5 = MD5String(buff) Then
'Password dung
CreatAFile buff, txtPath & ".decrypted"
MsgBox "Successfully! File has been decrypted with the extension (.decrypted)." & vbCrLf & "To open the file you need to rename it by removing extensions (.encrypted & .decrypted)."
Else
'Password sai
MsgBox "Wrong Password!"
End If
End If
Else
MsgBox "Not Found!"
End If
End If
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim strTmp As String
strTmp = Command()
DoEvents
txtPath.Text = strTmp
Set EncryptCryptAPI = New clsCryptAPI
End Sub
Private Sub txtPath_Change()
On Error Resume Next
Check
DoEvents
End Sub
Private Sub txtPath_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
'On Error Resume Next
txtPath = Data.Files(1)
Check
End Sub
Private Sub Check()
If FileExist(txtPath.Text) = True Then
cmdCom.Enabled = True
Dim buff As String
Dim strMD5 As String
buff = InputFile(txtPath)
Dim strR As String
strR = EncryptCryptAPI.DecryptString(Left(buff, 6), "dark")
If strR <> "eNcOdE" Then
'Neu du lieu chua duoc
cmdCom.Caption = "Encrypt"
lblSta.Caption = "The file is not Encrypted"
Else
cmdCom.Caption = "Decrypt"
lblSta.Caption = "The file is Encrypted"
End If
Else
cmdCom.Enabled = False
lblSta.Caption = "Not Found!"
End If
End Sub