寻求vb高速base64算法,谢谢

解决方案 »

  1.   

    http://www.cnblogs.com/tongnaifu/archive/2008/10/27/1320447.html
      

  2.   

    其实我做的是一个vb的截屏控件
    截屏生成的图片要转换为字节组然后base64编码生成字符串,当截屏的区域过大时,图片进行base64编码的时间很久
    请问有谁做过这样的功能的,如何解决base64编码的时间长的问题?
      

  3.   

    高效的?小仙妹的当之无愧。
    http://blog.csdn.net/KiteGirl/archive/2006/06/26/834851.aspx
      

  4.   

    查表虽然快,但是内存消耗太大,正向查表3:4,需要24bit表,16777216 * 4,约需要内存近67MB.至于解码,那只就需要近12.8G
      

  5.   

    理论上来讲,使用SSE指令,进行多路并行移位操作,应该是比较高效的,如果能同时处理128bit,那么就可以并行处理4路,虽然不能完全达到4倍的效率.
      

  6.   

    这里有一个,不知道速度怎么样,没测试过:Base64编码、解码类,支持中文 http://www.mndsoft.com/blog/article.asp?id=588
      

  7.   

    你可以参考一下开源的VBCorLib项目,在sourceforge上的下载的地址是http://sourceforge.net/projects/vbcorlib/官方网站是http://www.kellyethridge.com/vbcorlib/如果你不想知道的太多,可以直接注册VBCorLib.dll,其实这个dll实现了很多.Net类库中的功能,比如ArrayList,Hashtable,各种加密算法也是应有尽有
    最新版本是2.3下面是其关于Base64编码文件的一段代码'Text1中是一个文件名,测试的数据来看,3.5M左右的文件,Base64编码时间在0.1秒左右
    '下面的代码很简单不做解释
    ' Encodes a selected file into a Base64 string.
    Private Sub cmdEncode_Click()
        ' Lets check if the file exists and let the
        ' user know if we couldn't find it.
        If Not File.Exists(Text1.Text) Then
            MsgBox "File does not exist.", vbExclamation + vbOKOnly, "File Not Found."
            Exit Sub
        End If    ' We don't want to load large files into memory, so we
        ' will simply map it into memory.
        Dim map As MemoryMappedFile
        Set map = NewMemoryMappedFile(Text1.Text)
        
        ' And we will request a Byte array view of the mapped file.
        Dim view() As Byte
        view = map.CreateView
        
        ' We want to be cautious when we have a view of the mapped
        ' file, because we don't really own the Byte view. It is
        ' being loaned to us and we need to give it back, or bad
        ' things will happen.
        On Error GoTo errTrap
        
        ' Create our timing object to tell us how long it took to encode.
        Dim sw As StopWatch
        Set sw = StopWatch.StartNew
        
        ' Encode the file using our mapped view. Even though
        ' the entire file is not loaded into memory, a mapped view
        ' of a file is still extremely fast.
        Dim s As String
        s = Convert.ToBase64String(view, , , True)
        
        ' let the world know how long the encoding took.
        lblTime.Caption = sw.ElapsedMilliseconds
        
        ' And show other stats about the file and encoded string.
        lblFileLength = FileLen(Text1.Text)
        lblEncodedLength.Caption = Len(s)
        
        ' Finally show the encoded string in the textbox.
        RichTextBox1.Text = s
        
    errTrap:
        ' We have to delete the view we have borrowed before
        ' we close the mapped file, always.
        map.DeleteView view
        map.CloseFile
    End Sub