ok i've looked at a lot of the symmetric encryption algorithms, however, they usually only have up to 256bit keys eg AES.
so i have this code that allows any length file to be used for a text key (cryptkey). does this make the following algorithm stronger?
Code:Private Sub Crypt(Path As String, CryptKey As String, CryptNumber As Double)
' 1. loads file to be encrypted in Path, into a bite array
' 2. loads in any length file contained in CryptKey into a bite array and xors it
'against the stream of bits of file to be encrypted
If Len(Dir$(Path)) Then
Dim ba() As Byte, nba() As Byte, kba() As Byte, i&, n&, ff&
n = FileLen(Path)
ReDim ba(n - 1): ReDim nba(n - 1) ' Resize byte arrays to hold all bytes in file
ff = FreeFile
Open Path For Binary Access Read As #ff
Get #ff, , ba() ' read file into byte array
Close #ff
Kill Path ' kill existing file now have file in ba()
n = Len(CryptKey) ' get length of CryptKey
kba = StrConv(CryptKey, vbFromUnicode) ' convert CryptKey into byte array
Rnd -1 ' calling rnd with a negative number before randomize allows rnd sequence to be reproduced
Randomize CryptNumber
For i = 0 To UBound(ba)
nba(i) = ba(i) Xor kba(i Mod n) Xor Int(Rnd * 256) 'Xor each byte with a random number as well as CryptKey
Next i
ff = FreeFile
Open Path For Binary Access Write As #ff
Put #ff, , nba() ' Write encypted bytes back to file
Close #ff
End If
End Sub
