#124291 - 2004-08-04 04:31 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
363???
Code:
;!
Function vigenere($t,$k,optional $d)
DIM $j,$r,$,$p,$o,$y
For $j = 65 To 90
$ = CHR($j)+$+CHR($j+32)
Next
$p = "0123456789"+$
For $j = 1 To Len($t)
Do
$ = Left($k,1)
$k = Right($k,-1)+$
$y = InSTR($p,$)
Until $y
$ = SubSTR($t,$j,1)
;Lonk $o=$o+($=" ") -$o*($=!|$='?'|$='.')
;Modified $o=IIf($=!|$='?'|$='.',0,$o+($=" "))
$r = InSTR($p,$)
If $r
$ = 62 - (UCase($t+$k)=$t+$k)*26
$ = SubSTR($p,1+($+$r+(2*($d=0)-1)*($y-IIf($=!|$='?'|$='.',0,$o+($=" "))-2)-1) mod $,1)
EndIf
$vigenere = $vigenere + $
Next
EndFunction
;!
;!
Have to check word shift...
_________________________
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...
|
|
Top
|
|
|
|
#124297 - 2004-08-04 11:02 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
391 with correct word shift. Code:
Function vigenere($t,$k,optional $d) DIM $j,$r,$,$p,$o,$y For $j=65 To 90 $=CHR($j)+$+CHR($j+32) Next $p="0123456789"+$ For $j=1 To Len($t) Do $=Left($k,1) $k=Right($k,-1)+$ $y=InSTR($p,$) Until $y $=SubSTR($t,$j,1) $r=InSTR($p,$) $o=IIf(0<InSTR('! ? . ',$+SubSTR($t,$j+1,1)),-1,$o+($=' '))
If $r $=62-(UCase($t+$k)=$t+$k)*26 $=SubSTR($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1) EndIf $vigenere=$vigenere + $ 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...
|
|
Top
|
|
|
|
#124299 - 2004-08-05 02:31 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
Nope, both wrong; both solutions give:
'AA AA', 'A' ==> CC DD 'AA AA. AA AA', 'A' ==> CC DD. DD EE
The code could be 387 and be correct if Code:
$o=IIf(0<InSTR('! ? . ',SubSTR($t,$j,2)),-1,$o+($=' '))
this gives
'AA AA', 'A' ==> CC DD 'AA AA. AA AA', 'A' ==> CC DD. CC DD
Which in my opinion is correct.
_________________________
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...
|
|
Top
|
|
|
|
#124302 - 2004-08-08 02:30 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
with new rulebase, going to lead anyways, 382:
Code:
function vigenere($t,$k,optional $d) dim $j,$r,$,$p,$o,$y for $j = 65 to 90 $ = chr($j)+$+chr($j+32) next $p = "0123456789"+$ for $j = 1 to len($t) do $ = left($k,1) $k = right($k,-1)+$ $y = instr($p,$) until $y $ = substr($t,$j,1) $o = ($o+($=" "))*(0=instr('!?.',substr($t,$j-1,1))) $r = instr($p,$) if $r $ = 62 - (ucase($t+$k)=$t+$k)*26 $ = substr($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1) endif $vigenere = $vigenere + $ next endfunction
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|