Results 1 to 17 of 17

Thread: Vigenere (xor version) cipher

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Vigenere (xor version) cipher

    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?
    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
    My improvements to first version (much slower than this):
    -'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)
    Last edited by Ivenesco; May 24th, 2008 at 07:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width