标签:reader 加密 http 分享 int class har scanner etc
源代码:import java.util.*;
public class lizi {
public static void main( String args[] )
{
String str1,str2;
Scanner reader=new Scanner(System.in);
System.out.println("输入密码:");
str1=reader.next();
char[] arrey=new char[100];
str1.getChars(0,str1.length(),arrey,0);
System.out.println("加密后是:");
for(int i=0;i<str1.length();i++)
{
if((str1.charAt(i)>=65&&str1.charAt(i)<=87)||(str1.charAt(i)>=97&&str1.charAt(i)<=119))
arrey[i]=(char)(arrey[i]+3);
else
arrey[i]=(char)(arrey[i]-23);
System.out.print(arrey[i]);
}
System.out.println("\n输入密码:");
str2=reader.next();
char[] arr=new char[100];
str2.getChars(0,str2.length(),arr,0);//同上
System.out.println("解密后是:");
for(int i=0;i<str2.length();i++)
{
if((str2.charAt(i)>=68&&str2.charAt(i)<=90)||(str2.charAt(i)>=100&&str2.charAt(i)<=122))
arr[i]=(char)(arr[i]-3);
else
arr[i]=(char)(arr[i]+23);
System.out.print(arr[i]);
}
reader.close();
}
}
截图:
标签:reader 加密 http 分享 int class har scanner etc
原文地址:http://www.cnblogs.com/y862621115/p/7738319.html