码迷,mamicode.com
首页 > 其他好文 > 详细

采用字符的移位方式实现字符文本加密解密。

时间:2016-09-16 00:08:45      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

Scanner sc=new Scanner(System.in);
System.out.println("需要解密的内容是");
String str=sc.nextLine();//输入解密前的内容

System.out.print("您的内容解密之后是:"+str.replaceAll("A", "c").replaceAll("B", "d").replaceAll("C", "e")
.replaceAll("D", "f").replaceAll("E", "g").replaceAll("F", "h").replaceAll("G", "i").replaceAll("H", "j")
.replaceAll("I", "k").replaceAll("J", "l").replaceAll("K", "m").replaceAll("L", "n").replaceAll("M", "o")
.replaceAll("N", "p").replaceAll("O", "q").replaceAll("P", "r").replaceAll("Q", "s").replaceAll("R", "t")
.replaceAll("S", "u").replaceAll("T", "v").replaceAll("U", "w").replaceAll("V", "x").replaceAll("W", "y")
.replaceAll("X", "z").replaceAll("Y", "a").replaceAll("Z", "b"));//解密后的内容

技术分享

 

采用字符的移位方式实现字符文本加密解密。

标签:

原文地址:http://www.cnblogs.com/diaozhaojian/p/5875632.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!