各位大虾,小弟刚学vb没两天,按老师要求做一个数据加密的小软件(内容如下所示)班里几个学vb有一段时间的同学全是做管理系统之类的东西,这方面帮不上忙,想来想去,决定在这里发个帖子试一试:)谢谢各位大虾先:)
数据加密软件设计原理及要求原理:
  BMP文件时windows采用的图形文件格式,是WINDOWS系统内部各种图形操作的基础。其文件分四个部分:位图文件头(用来显示加密后文件大小的变化的)、位图信息头、彩色表和图像数据阵列。其中位图文件头包含了位图文件的长度。它自身的结构特性是WINDOWS依靠次文件信息对位图文件进行操作,并不理会实际文件的长度。这样就有了用BMP文件作加密文件的载体的前提条件----可以将数据文件连接到位图文件的后面。
要求:
1.加密时判断位图文件是否含有加密文件
2.加密和解密功能
3.解密时判断可否加密文件
4.正确分离位图文件和数据文件(*.txt我是这么理解的)我的QQ号是:86757936
邮箱是[email protected](饶了我的邮箱吧,别再炸了:(谢谢先) 
谢谢各位了:)

解决方案 »

  1.   

    Option Explicit
    Private Declare Sub MoveMemory Lib "kernel32" Alias "Rtlmovememory" (destination As Any, source As Any, source As Any, ByVal length As Long)Private Sub Command1_Click()
    On Error GoTo myerr
    CommonDialog1.Filter = "bmp files(*.bmp)|*.bmp"
    CommonDialog1.FileName = ""
    CommonDialog1.CancelError = True
    CommonDialog1.ShowOpen
    Dim picfilename As String
    If picfilename = "" Then Exit Sub
    Dim picfilelen As Long
    picfilelen = FileLen(picfilename)
    Picture1.Picture = LoadPicture(picfilename)
    Dim templen As Long
    SavePicture Picture1.Picture, App.Path + "\temp.bmp"
    templen = FileLen(App.Path + "\temp.bmp")
    Kill App.Path + "temp.bmp"
    If picfilelen > templen Then
      MsgBox "该经过加密处理,不用再加密了!  "
      Exit Sub
    End If
    Dim txtfilename As String
    CommonDialog1.Filter = "txtfile(*.txt)|*.txt"
    CommonDialog1.CancelError = True
    CommonDialog1.FileName = ""
    CommonDialog1.ShowOpen
    txtfilename = CommonDialog1.FileName
    Dim txtfilelen As Long
    txtfilelen = FileLen(txtfilename)
    Dim mbyte() As Byte
    ReDim mbyte(txtfilelen - 1)
    Open txtfilename For Binary As 1
    Get 1, , mbyte
    Close 1
    Dim nbyte() As Byte
    ReDim nbyte(picfilelen - 1)
    Open picfilename For Binary As 3
    Get 3, , nbyte
    Close 3
    ReDim Preserve nbyte(picfilelen + txtfilelen - 1)
    MoveMemory nbyte(picfilelen), mbyte(0), txtfilelen
    Open picfilename For Binary As 2
    Put 2, , nbyte
    Close 2
    Exit Sub
    myerr:
      Select Case Err.Number
      Case 32755
      MsgBox " 请选择一个文件"
      Case 53
      MsgBox "文件不存在或路径错误"
      End Select
    End SubPrivate Sub Command2_Click()
    On Error GoTo myerr
    CommonDialog1.Filter = "bmp files(*.bmp)|*.bmp"
    CommonDialog1.FileName = ""
    CommonDialog1.CancelError = True
    CommonDialog1.ShowOpen
    Dim picfilename As String
    picfilename = CommonDialog1.FileName
    If picfilename = "" Then Exit Sub
    Dim picfilelen As Long
    picfilelen = FileLen(picfilename)
    Picture1.Picture = LoadPicture(picfilename)
    Dim templen As Long
    SavePicture Picture1.Picture, App.Path + "\temp.bmp"
    templen = FileLen(App.Path + "\temp.bmp")
    Kill App.Path + "\temp.bmp"
    If picfilelen = templen Then
    MsgBox "该文件还没有经过加密处理!"
    Exit Sub
    End If
    Dim txtfilename As String
    Dim txtfilelen As Long
    CommonDialog1.Filter = "txt files(*.txt|*.txt)"
    CommonDialog1.CancelError = True
    CommonDialog1.FileName = ""
    CommonDialog1.ShowSave
    txtfilename = CommonDialog1.FileName
    Dim txtfilelenas As Long
    txtfilelen = picfilelen - templen
    Dim mbyte() As Byte
    ReDim mbyte(txtfilelen - 1)
    Dim nbyte() As Byte
    ReDim nbyte(picfilelen - 1)
    Open picfilename For Binary As 3
    Get 3, , nbyte
    Close 3MoveMemory mbyte(0), nbyte(templen + 1), txtfilelen
    Open txtfilename For Binary As 2
    Put 2, , mbyte
    Close 2
    Exit Sub
    myerr:
     Select Case Err.Number
     Case 32755
     MsgBox "请选择一个文件"
     Case 53
     MsgBox "文件不存在或路径错误"
     End Select
     End Sub
     
    Private Sub Command3_Click()
    Unload Me
    End SubPrivate Sub Form_Load()
    Picture1.Visible = FalseEnd Sub程序出来了应该没问题了,可调试时说编译错误,参数不可选  光标停在movememory处,代码是打进去的,api 浏览器中找不到movememory挺急的 还请多多帮忙:)
      

  2.   

    文件夹带算法的实现:
    http://www.applevb.com/sourcecode/Basic%20Steganography.zip
      

  3.   

    Private Declare Sub MoveMemory Lib "kernel32" Alias "Rtlmovememory" (destination As Any, source As Any, source As Any, ByVal length As Long)
    怎么两个source As Any,去掉一个试试