加密程序

加密方法:

import javax.swing.JOptionPane;
public class 解码 {
    public static void main(String args[])
    {
        String output="";
        int xuanze=Integer.parseInt(JOptionPane.showInputDialog("1.解码,2.转码,输入:"));
        if(xuanze==1)
        {
            String jiema=JOptionPane.showInputDialog("请输入所需解码的数据:");
            int length=jiema.length();
            int i=0;
            while(length>0)
            {
                char zi=jiema.charAt(i);
                if(zi==88||zi==89||zi==90||zi==120||zi==121||zi==122)zi-=23;
                else if(zi!=32)
                    zi+=3;
                output+=zi;
                i++;
                length--;
            }
            JOptionPane.showMessageDialog(null,"解码的结果:"+output);
        }
        else if(xuanze==2)
        {
            String jiema=JOptionPane.showInputDialog("请输入所需转码的数据:");
            int length=jiema.length();
            int i=0;
            while(length>0)
            {
                char zi=jiema.charAt(i);
                if(zi==97||zi==98||zi==99||zi==65||zi==66||zi==67)zi+=23;
                else if(zi!=32)
                    zi-=3;
                output+=zi;
                i++;
                length--;
            }
            JOptionPane.showMessageDialog(null,"解码的结果:"+output);
        }
        else 
            JOptionPane.showMessageDialog(null,"输入错误!!");
    }

}

 

结果截图:

posted @ 2015-10-25 22:12  TmT  阅读(196)  评论(0编辑  收藏  举报