日期:2014-05-16 浏览次数:20385 次
<script type="text/javascript">
var str=prompt("请输入要加密的字符串:").split("");
var newStr=[];
var alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
for(var n=0; n<=str.length; n++)
for(var i=0; i<=25;i++)
if(str[n]==alphabet[i])
if(i+5<=25)
newStr[n]=alphabet[i+5];
else
newStr[n]=alphabet[i+5-26];
alert("加密后的新字符串是:"+newStr.join(""))
</script>
switch(str[n]){
case str[n]==alphabet[i]&&i+5<=25:
newStr[n]=alphabet[i+5];
break;
case str[n]==alphabet[i]&&i+5>25:
newStr[n]=alphabet[i+5-26];
}
<script type="text/javascript">
var str=prompt("请输入要加密的字符串:").split("");
var newStr=[];
var alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
for(var n=0; n<=str.length; n++)
for(var i=0; i<=25;i++)
switch(str[n]){
case str[n]==alphabet[i]&&i+5<=25:
newStr[n]=alphabet[i+5];
break;
case str[n]==alphabet[i]&&i+5>25:
newStr[n]=alphabet[i+5-26];
}
alert("加密后的新字符串是:"+newStr.join(""));
</script>