I have created a simple program to achieve something for a friend but it involves reading a file and then recreating it with adjustments to encrypt it. The problem is...it takes FAR too long. A good couple of minutes for a 4 megabyte file.
The code I currently have is as follows:
Dim ArrayNum As Long
Dim EncryptNum As Long
Dim FileLen As Long
Dim FileArray() As Byte
Open File For Binary As #Free
FileLen = LOF(Free)
Get #Free, , FileArray(ArrayNum)
ArrayNum = ArrayNum + 1
Loop Until EOF(Free)
Open File & "enc" For Output As #Free
Open File & "enc" For Binary As #Free
Put #Free, EncryptNum + 1, FileArray(EncryptNum) + 1
EncryptNum = EncryptNum + 1
Loop Until EncryptNum = FileLen
I would like it if someone could give me some advice or touch up my code or even replace it if necessary. Also, I do not know how to use API calls yet so I would like it if the suggestions and possible solutions left them out.
Also larger files tend to give an out of memory error. Any suggestions in overcoming this hurdle?