Java 简单实现Enigma英格玛密码

package egnima;
import java.util.Scanner;
public class enigma {
static public void main(String []args)
{
Scanner cin=new Scanner(System.in);
System.out.print("Input 0 to encode message and 1 to decode message:");
int op=cin.nextInt();
if(op==0)
encode();
	else
	decode();
}
static void encode()
{
	String msg="";
	String encodemsg="";
	int count=0;
	System.out.printf("%s","Input the message:");
	Scanner cin=new Scanner(System.in);
	msg=cin.nextLine();
	for(int i=0;i'z')
			decodemsg+=(char)(msg.charAt(i)-26+count);
			else
			decodemsg+=(char)(msg.charAt(i)+count);
		count++;
	}
	System.out.println(decodemsg);
}

}

你可能感兴趣的:(Java,Java,Enigma,英格玛)