You can try the AesChunkedCryptArray function in mdAesCtr.bas with something like this
These couple of functions (AesChunkedXxx) allow reading and encrypting a file in chunks.Code:Private Sub TestEncrypt4() Dim baKey() As Byte Dim baInput() As Byte Dim baEncr1() As Byte Dim baEncr2() As Byte Dim baEncr3() As Byte Dim baDecr() As Byte baKey = StrConv("32-byte secret key and 16-byte IV", vbFromUnicode) Debug.Assert UBound(baKey) >= 31 And UBound(baKey) <= 47 baInput = "this is a chunk this is a chunk this is a chunk" If Not AesChunkedInit(baKey) Then GoTo QH End If If Not AesChunkedCryptArray(baInput, baEncr1, Final:=False) Then GoTo QH End If Debug.Print DesignDumpArray(baEncr1) If Not AesChunkedCryptArray(baInput, baEncr2, Final:=False) Then GoTo QH End If Debug.Print DesignDumpArray(baEncr2) If Not AesChunkedCryptArray(baInput, baEncr3) Then GoTo QH End If Debug.Print DesignDumpArray(baEncr3) If Not AesChunkedInit(baKey) Then GoTo QH End If If Not AesChunkedCryptArray(baEncr1, baDecr, Final:=False) Then GoTo QH End If If Not AesChunkedCryptArray(baEncr2, baDecr, Final:=False) Then GoTo QH End If If Not AesChunkedCryptArray(baEncr3, baDecr) Then GoTo QH End If Debug.Print DesignDumpArray(baDecr) Exit Sub QH: MsgBox AesChunkedGetLastError, vbCritical End Sub
Note that this is AES in Counter mode (not CBC) and the implementation is not compatible with Windows XP.
cheers,
</wqw>




Reply With Quote
