Vigenere.lenCpr = Vigenere._strCpr.length;
Vigenere.Encrypt = function(K,P){//加密算法,K为密钥,P为明文 Vigenere.DisEncrypt = function(K,C){
K = Vigenere._strKey(K,P);
var lenK = K.length;
var rlt = '';
var loop = 0;
for(loop=0; loop
if(iP==-1) return '本算法暂时不能对字符:' + P.charAt(loop) + '进行加密';
var iK = Vigenere._strCpr.indexOf(K.charAt(loop));
if(iK==-1) return '密钥中包含非法字符:' + K.charAt(loop);
var i = (iP + iK) % Vigenere.lenCpr;
rlt = rlt + Vigenere._strCpr.charAt(i);
}
return rlt;
};
K = Vigenere._strKey(K,C);
var lenK = K.length;
var rlt = '';
var loop = 0;
for(loop=0; loop
if(iK==-1) return '密钥中包含非法字符:' + K.charAt(loop);
var iC = Vigenere._strCpr.indexOf(C.charAt(loop));
if(iK > iC){
rlt += Vigenere._strCpr.charAt(iC + Vigenere.lenCpr - iK);
}
else{
rlt += Vigenere._strCpr.charAt(iC - iK);
}
}
return rlt;
};