Re: Byte Array Speed
From: Bill-R (BillR_at_yahoo.com)
Date: 04/29/04
- Next message: Mark Durrenberger: "Invalid Clipboard Format"
- Previous message: Schmidt: "Re: Byte Array Speed"
- In reply to: Schmidt: "Re: Byte Array Speed"
- Next in thread: Bob O`Bob: "Re: Byte Array Speed"
- Reply: Bob O`Bob: "Re: Byte Array Speed"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 28 Apr 2004 17:32:53 -0700
Thanks for the reply ;
Here is The Sub that I use to do the cipher
Private Sub Bcipher()
On Error GoTo DoCerror
Dim InMask As String * 6
Dim Mask(6) As Byte
Dim i As Long
Dim x As Integer
Dim y As Integer
Dim c1 As Long
Dim InA() As Byte
Dim OutA() As Byte
Dim Eflg As String * 2
InMask = Password
Mask(1) = Asc(Mid$(InMask, 1, 1))
Mask(2) = Asc(Mid$(InMask, 2, 1))
Mask(3) = Asc(Mid$(InMask, 3, 1))
Mask(4) = Asc(Mid$(InMask, 4, 1))
Mask(5) = Asc(Mid$(InMask, 5, 1))
Mask(6) = Asc(Mid$(InMask, 6, 1))
TempPathName = "c:\temp.dat"
For x = 1 To NumOfFiles
Eflg = "OI"
Open InfileArray(x) For Binary As #2
Eflg = "OO"
Open TempPathName For Binary As #1
c1 = LOF(2)
ReDim InA(1 To c1)
ReDim OutA(1 To c1)
GetDat:
Eflg = "GI"
Get #2, , InA
i = 1
DoCipher:
For y = 1 To 6 'cypher
OutA(i) = Mask(y) Xor InA(i)
If i = c1 Then GoTo PutOut
i = i + 1
Next y
GoTo DoCipher
PutOut:
Eflg = "PO"
Put #1, , OutA
CleanUp:
Eflg = "C1"
Close #1
Eflg = "C2"
Close #2
Eflg = "KI"
Kill InfileArray(x) 'Del Orig File
Eflg = "CF"
FileCopy TempPathName, InfileArray(x)
Eflg = "KO"
Kill TempPathName
Next x
If NumOfFiles = 1 Then
MsgBox " 1 File Has Been Ciphered/De-Ciphered"
Exit Sub
End If
MsgBox NumOfFiles & " Files Have Been Ciphered/De-Ciphered"
DoneIt:
Exit Sub
DoCerror: MsgBox "File Error In Do Cipher " & Eflg
End Sub
"Schmidt" <sss@online.de> wrote in message
news:uWR6W8XLEHA.808@tk2msftngp13.phx.gbl...
>
> "Bill-R" <BillR@yahoo.com> schrieb im Newsbeitrag
> news:%23h50D0XLEHA.3516@TK2MSFTNGP11.phx.gbl...
> > Years ago I wrote a simple Cipher program in DOS Assembler.
> > I take a 6 Byte Password then XOR it to six Bytes of the Target file
then
> > write out
> > the XOR'ed Bytes to a new file.
> >
> > I tried to do this in VB by Reading the Target file into a byte array ,
> then
> > proceeding as I did in the .asm program.
> >
> > It Is so Slow .....
> >
> > I find it 10 times faster to exit to a .asm Prog to do the Cipher. and
> just
> > use the VB Program for a nice interface !
> >
> > Is there a faster way to accomplish this In Pure VB ???
>
> VB-Code (compiled to Native-Code with all options) shouldn't be much
slower
> in such Ops than Assembler.
> Just show us your VB-Code.
> How long needs the ASM-Code, to convert a file with a specified Size?
> What Time has you measured with VB (native-Compiled)?
>
> Olaf
>
>
- Next message: Mark Durrenberger: "Invalid Clipboard Format"
- Previous message: Schmidt: "Re: Byte Array Speed"
- In reply to: Schmidt: "Re: Byte Array Speed"
- Next in thread: Bob O`Bob: "Re: Byte Array Speed"
- Reply: Bob O`Bob: "Re: Byte Array Speed"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|