我想做一个加密解密文件的VB程序!用des加密解密方法!!! 希望高手解答!

1.“选择文件”按钮代码,打开的文件名称在右边显示。2.“随即密码”的按钮代码,随机出来密码在右边显示。右边的框也可以用来输入自己的密码!3“加密”按钮代码4。“解密”按... 1.“选择文件”按钮代码,打开的文件名称在右边显示。
2.“随即密码”的按钮代码,随机出来密码在右边显示。右边的框也可以用来输入自己的密码!
3“加密”按钮代码
4。“解密”按钮代码。
就这么多了!
对选择的文件加密后,其文件名前加“JM”另存!
随机密码可以不用!不过 还是要能够输入自己想的密码进行加密!
解密对已经加密的文件后文件名还原!!
展开
 我来答
zhaobuping
2011-05-17 · TA获得超过340个赞
知道小有建树答主
回答量:195
采纳率:0%
帮助的人:268万
展开全部
vb.net code注意随机密码按钮在没用,调试时你自己输入密码,一定为8位,我是将文件存在D盘,你自己在修改一下,那个就很简单
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sSecretKey As String = Me.TextBox2.Text
EncryptFile(Me.TextBox1.Text, "D:\JMtest.txt", sSecretKey)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sSecretKey As String = Me.TextBox2.Text
DecryptFile("D:\JMtest.txt", "D:\Decrypted.txt", sSecretKey)
End Sub
Sub EncryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String)
Dim fsInput As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
Dim fsEncrypted As New FileStream(sOutputFilename, FileMode.Create, FileAccess.Write)
Dim DES As New DESCryptoServiceProvider
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey)
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
Dim desencrypt As ICryptoTransform = DES.CreateEncryptor()
Dim cryptostream As New CryptoStream(fsEncrypted, desencrypt, CryptoStreamMode.Write)
Dim byteArrayInput(fsInput.Length - 1) As Byte
fsInput.Read(byteArrayInput, 0, byteArrayInput.Length)
cryptostream.Write(byteArrayInput, 0, byteArrayInput.Length)
cryptostream.Close()
End Sub
Sub DecryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String)
Dim DES As New DESCryptoServiceProvider
DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey)
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor
Dim cryptostreamDecr As New CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read)
Dim fsDecrypted As New StreamWriter(sOutputFilename)
fsDecrypted.Write(New StreamReader(cryptostreamDecr, System.Text.ASCIIEncoding.Default).ReadToEnd)
fsDecrypted.Flush()
fsDecrypted.Close()
End Sub
Private Sub BtnChoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnChoose.Click
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "txt files (*.txt)|*.txt"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
Me.TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
End Class
匿名用户
2011-05-10
展开全部
你的疑问在哪?。。要给你全部源文件。显然不现实。
追问
des加密解密的VB代码不懂!VC++倒还懂一点点!代码部分的所有的置换表度没必要写!你就用XX置换表代替!(如初始置换表)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式