Who can improve it? On 1 core 2,8 Ghz it works with speed above 370 MB/s.
Is there any hints, to code it better?
My improvements to first version (much slower than this):Code:Function Vigenere(ByRef input() As Byte, ByRef key() As Byte) As Byte() Dim intKey As Integer = 0 Dim x As Integer = input.Length - 1 Dim x2 As Integer = key.Length For i As Integer = 0 To x If intKey = x2 Then intKey = 0 End If input(i) = input(i) Xor key(intKey) intKey += 1 Next End Function
-'ByRef' instead of 'ByVal'
-for i as integer...(and if ... then) ended with variable (x or x2) instead of length calculating each time
-'if intKey = 0' statement to choose key from array is much faster than:
Code:input(i) = input(i) Xor key(i mod key.Length)




Reply With Quote