Home Forums ActiveX components Xceed Encryption for ActiveX Decrypt file to memory in VB6

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42974 |

    Hello group –

    How can I decrypt a file to memory in VB6? I want to do it WITHOUT creating an intermediate decrypted file on file system.

    I see the ReadFile method, but it reaturns a byte array, and I can’t figure out how to convert the byte array to a string. Any help would be greatly appreciated.

    David

    Imported from legacy forums. Posted by David (had 5061 views)

    User (Old forums)
    Member
    Post count: 23064

    I have resolved the problem. I’ll post the solution here in case anyone else runs into this issue.

    The problem:
    When encrypting large strings (1 million or more characters), encryption was very slow in VB6 environment. I was attempting to use some of the file encyption methods to work around this problem, but I found a better way.

    The solution:
    The problem was in the BinaryToHex function provided in one of the sample apps. String operations in VB6 are hellishly slow, and concantenating 1 million plus characters was bringing the process to a standstill. I rewrote the function as follows, and it’s now much faster:

    Private Function BinaryToHex(ByRef vaBinaryValue As Variant) As String
    Dim i As Long
    Dim buffer() As String

    ReDim buffer(LenB(vaBinaryValue) – 1)

    If (VarType(vaBinaryValue) And vbArray) = vbArray Then
    For i = 0 To LenB(vaBinaryValue) – 1
    buffer(i) = (Right(“0” & Hex(CLng(vaBinaryValue(i))), 2))
    Next i
    End If

    BinaryToHex = Join(buffer, “”)

    End Function

    Hope that helps someone else out there someday.

    Imported from legacy forums. Posted by David (had 7921 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.