用JAVA写的一个破解Vigenere的程序,运行成功,但是没有结果.不知道为什么....
Exception in thread "main "
java.lang.ArrayIndexOutOfBoundsException: 6
at Vigenere.figureOutKeyLength(DecoderAndEncoder.java:74)
at DecoderAndEncoder.main(DecoderAndEncoder.java:38)
Java Result: 1
debug-single:
生成成功(总时间:1 秒)
import java.util.*;
import java.text.*;
public class DecoderAndEncoder {
/** Creates a new instance of DecoderAndEncoder */
public static void main(String[] args)
{
String originalCode= "hdsfgvmkoowafweetcmfthskucaqbil " +
"gjofmaqlgspvatvxqbiryscpcfrmvswrvnqlszdmgao " +
"qsakmlupsqforvtwvdfcjzvgsoaoqsacjkbrsevbelv " +
"bksarlscdcaarmnvrysywxqgvellcyluwwveoafgcla " +
"zowafojdlhssfiksepsoywxafowlbfcsocylngqsyzx " +
"gjbmlvgrggokgfgmhlmejabsjvgmlnrvqzcrggcrghg " +
"eupcyfgtydycjkhqluhgxgzovqswpdvbwsffsenbxap " +
"asgazmyuhgsfhmftayjxmwznrsofrsoaopgauaaarmf " +
"tqsmahvqecev ";//要破译的密文
int[] statu=new int[6];
Vigenere myCode=new Vigenere(originalCode);
for(int i=0;i <6;i++)
{
String temp=myCode.moveLeft(i);
statu[i]=myCode.compareIt(originalCode,temp);
}
keyLength=myCode.figureOutKeyLength(statu);//報錯說這一行也有錯誤
int[] key=new int[keyLength];
for(int j=0;j <keyLength;j++)
{
key[j]=myCode.findKey(j,keyLength);