Results 1 to 28 of 28

Thread: [RESOLVED] Aes encryption worked on windows 7 and win 10 but notworkd on winxp!!! how fix that?

Threaded View

  1. #19

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    591

    Re: [RESOLVED] Aes encryption worked on windows 7 and win 10 but notworkd on winxp!!


    i tested this on windows xp/7/10 64bit and worked good with huge files.

    i changed some part with this :
    Code:
    Private Sub EncryptFile(sSrcFile As String, sDestFile As String, baKey() As Byte)
        ' fixed error about main files size smaller than chunk difination
      
        Dim CHUNK_SIZE  As Long
    
        Dim pInput      As stdole.IUnknown
    
        Dim pOutput     As stdole.IUnknown
    
        Dim baChunk()   As Byte
    
        Dim dblTimer    As Double
        
        Dim lSize       As Currency
    
        Dim Chunkreaded As Currency
        
        dblTimer = Timer
    
        AesChunkedInit baKey
        Set pInput = StreamOpenFile(sSrcFile)
        Set pOutput = StreamOpenFile(sDestFile, AlwaysCreate:=True)
        
        lSize = StreamGetSize(pInput)
        ' if size of file smaller than chunksize
    
        If lSize < (1024@ * 1024 * 2) Then CHUNK_SIZE = lSize Else CHUNK_SIZE = 1024@ * 1024 * 2 ' x mb
        Chunkreaded = 31 ' extra  byte
        p.Value = 0
        p.Caption1 = p.Value & " %"
        p.Caption2 = ""
    
        Do
            DoEvents
            
            baChunk = StreamReadBytes(pInput, CHUNK_SIZE)
    
            If UBound(baChunk) < 0 Then
    
                Exit Do
    
            End If
    
            Chunkreaded = Chunkreaded + UBound(baChunk) + 1 ' +1  added because of UBound
    
            ' progress
            p.Caption2 = lSize & " / " & Chunkreaded
            
    
            If CHUNK_SIZE = lSize Then
                ' progress
                p.Value = 100
                p.Caption1 = p.Value & " %"
            Else
                ' progress
                p.Value = Fix(CCur((Chunkreaded * 100) / lSize))
                p.Caption1 = p.Value & " %"
            End If
    
            
            DoEvents
    
            AesChunkedEncryptArray baChunk, baChunk, Final:=StreamEOF(pInput)
            StreamWriteBytes pOutput, baChunk
        Loop
        ' progress    
        p.Caption2 = lSize & " / Elapsed " & Format$(Timer - dblTimer, "0.000")
        p.Value = 100
        p.Caption1 = p.Value & " %"
    End Sub
    
    Private Sub DecryptFile(sSrcFile As String, sDestFile As String, baKey() As Byte)
    
        ' fixed error about main files size smaller than chunk difination
      
        Dim CHUNK_SIZE  As Long
        
        Dim pInput      As stdole.IUnknown
    
        Dim pOutput     As stdole.IUnknown
    
        Dim baChunk()   As Byte
    
        Dim dblTimer    As Double
    
        Dim lSize       As Currency
    
        Dim Chunkreaded As Currency
        
        dblTimer = Timer
        AesChunkedInit baKey
        Set pInput = StreamOpenFile(sSrcFile)
        Set pOutput = StreamOpenFile(sDestFile, True)
        
        lSize = StreamGetSize(pInput)
        
        ' if size of file smaller than chunksize
    
        If lSize < (1024@ * 1024 * 2) Then CHUNK_SIZE = lSize Else CHUNK_SIZE = 1024@ * 1024 * 2 ' x mb
        Chunkreaded = 0 ' extra  byte
        ' progress
        p.Value = 0
        p.Caption1 = p.Value & " %"
    
        Do
            
            baChunk = StreamReadBytes(pInput, CHUNK_SIZE)
            
            If UBound(baChunk) < 0 Then
    
                Exit Do
    
            End If
            
            Chunkreaded = Chunkreaded + UBound(baChunk) + 1 ' +1  added because of UBound
    
            ' progress
            p.Caption2 = lSize & " / " & Chunkreaded
            
            If CHUNK_SIZE = lSize Then
                ' progress
                p.Value = 100
                p.Caption1 = p.Value & " %"
            Else
                ' progress
                p.Value = Fix(CCur((Chunkreaded * 100) / lSize))
                p.Caption1 = p.Value & " %"
            End If
    
            DoEvents
            AesChunkedDecryptArray baChunk, baChunk, Final:=StreamEOF(pInput)
            StreamWriteBytes pOutput, baChunk
        Loop
    
        ' progress
        p.Caption2 = lSize & " / Elapsed " & Format$(Timer - dblTimer, "0.000")
        p.Value = 100
        p.Caption1 = p.Value & " %"
        
    End Sub

    i attached test program :
    test.zip

    Quote Originally Posted by fafalone View Post
    @Black_Storm,
    1- If you're running from the IDE what wqweto posted the lag will be from the Debug.Print.

    2- Add a counter to the loop, get the total file size, divide it by the chuck size, your progress % is the counter value / chunks.

    3- Before you go any farther with this idea, how much video data do you need to be able to store? Because we can solve this problem right now if it's more than 4GB: Not possible.

    Then even if you're not facing that hard limit, you need to be aware to do what you're asking, editing live running code, you're going to be running up against anti-virus and OS anti-malware security features that won't be big fans of your self-modifying exe. You can get around those, but it's even more added complexity, which is nothing compared to the final problem: Some of the code will be running from memory as Windows maps the exe file and loads what's needed, so you're going to have some horrific crashes as those get out of sync if things aren't handled perfectly.

    I don't know if it's you or someone you're working for that's so dead set against having a 2nd file, but however difficult this may seem, convincing them or yourself a 2nd file isn't going to make the difference whether you get cracked or not will definitely be the easier route.
    1-Before asking the question in #15, I had converted all the debugs to caption=xxx or label.caption=xxx and then asked the question, but I solved the problem by setting the timer control, but still my question 1 remains in #15 and is about memory and slow occupation. The speed of the computer is working at high volumes. Can the memory be optimized here like the previous HugeBinaryFile class (autoflush method)?

    2-I sent the code I added and changed above so solved that question.

    3- The number of videos is not known, but the size of each file can be estimated up to 300 to 400 MB, and the number of files may reach 10. But if we consider the number of files less than 4 GB, what is the solution?

    Yes, I know about editing running code, and I've talked enough about it before in the threads I created.
    I do not work for a specific person and the company has many people, I have done this before with less features and work with separate files, but this time it is different, the files must be inside the executable file.

    I'm still looking for question 3 on how to play this file without having to save it to disk.
    For example, if I have an encrypted file with a size of 300 or 400 MB, but I want to decrypt it and play it without having to write it to disk, what should I do?
    My two issues
    1- How to decrypt without saving to disk
    2- Play formats such as mp4 or mkv in the program.
    Last edited by Black_Storm; Feb 22nd, 2022 at 10:18 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width