91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

vb中如何在數據文件加密碼

九三
219
2021-01-18 09:27:17
欄目: 編程語言

vb中如何在數據文件加密碼

通過使用以下vb函數,對數據文件進行加密,代碼如下:

Option Explicit

Dim i As Long

Dim databuff As Byte //定義數組用于存放文件內容

Dim addbuff As Byte //定義數組用于存放加密后的文件內容

Dim password As Byte //定義數組用于存放密碼的ASCII值

Dim filename As String

Private Sub Check1_Click

If Check1.Value Then //控制是否顯示全部文件

File1.Pattern = "."

Else

File1.Pattern = ".txt"

End If

End Sub

Private Sub Command1_Click

Dim j As Integer

Dim password_len As Integer

password_len = LenText2.Text

ReDim passwordpassword_len As Byte

For i = 0 To password_len - 1 //把密碼轉化為ASCII碼

password i = AscMidText2.Text i + 1 1

Next

If filename = "" Then Exit Sub

Open filename For Binary As #1 //讀取要加密的文件內容

ReDim databuffLOF1

Get #1 databuff

Close #1

ReDim addbuffUBounddatabuff As Byte

For i = 0 To UBound databuff

If j >= password_len Then //循環使用密碼

j = 0

Else

j = j + 1

End If

addbuff i = databuff i Xor password j //進行異或運算

Next

Open filename For Binary As #1 //把加密后的內容寫入文件

Put #1 addbuff

Close #1

Text1 = StrConvaddbuff vbUnicode //顯示加密后的文件內容

Text2.Text = ""

End Sub

Private Sub Command2_Click

End

End Sub

Private Sub Dir1_Change

File1.Path = Dir1.Path //與文件列表框相關聯

End Sub

Private Sub Drive1_Change

On Error GoTo a0

Dir1.Path = Drive1.Drive //與目錄列表框相關聯

a0 If Err Then MsgBox ErrorErr '發生錯誤,提示錯誤內容

End Sub

Private Sub File1_Click //單擊文件時,顯示文件內容

filename = Dir1.Path + File1.filename

If filename = "" Then Exit Sub

Open filename For Binary As #1

ReDim databuff LOF 1

Get #1 databuff

Close #1

Text1 = StrConv databuff vbUnicode

End Sub

0
大余县| 遵义市| 绵竹市| 淮北市| 庆云县| 安仁县| 湘乡市| 上杭县| 红河县| 鸡泽县| 若羌县| 梁山县| 台中市| 沾益县| 肃宁县| 苏尼特右旗| 中方县| 望都县| 六盘水市| 读书| 永顺县| 霍林郭勒市| 临西县| 合肥市| 黄大仙区| 读书| 晴隆县| 霍林郭勒市| 县级市| 阳春市| 连平县| 施秉县| 靖远县| 四平市| 赣榆县| 仙游县| 唐山市| 弋阳县| 万盛区| 卫辉市| 舒兰市|