569, no word shift:

Code:

Function Vigenere($a,$b, optional $c)
Dim $t,$u,$i,$j
$t='0123456789ZYXWVUTSRQPONMLKJIHGFEDCBA'
$u='abcdefghijklmnopqrstuvwxyz'

;remove wrong chars in key
For $i=1 to Len($b)
If InStr($t+$u,SubStr($b,$i,1))
$j=$j+SubStr($b,$i,1)
EndIf
Next

$b=$j

;check for lowercase in string/key, if so expand tableau
$j=Len($a)+Len($b)
For $i=1 to $j
If InStr($u,SubStr($a,$i,1)) OR InStr($u,SubStr($b,$i,1))
$t=$t+$u
$i=$j
EndIf
Next

;double the tableau
$t=$t+$t

;make the key larger than the string
While Len($b) < Len($a)
$b=$b+$b
Loop

For $i=1 to Len($a)
$j=SubStr($a,$i,1)
$u=SubStr($b,$i,1)
If InStr($t,$j)
If $c
$j=SubStr($t,InStrRev($t,$j)+Len($t)/2-InStrRev($t,$u)+1,1)
Else
$j=SubStr($t,InStr($t,$j)+InStr($t,$u)-1,1)
EndIf
EndIf
$vigenere=$vigenere+$j
Next

EndFunction

_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...