Java uses the HashMap class to implement string encryption and decryption with a simple substitution cipher.
发布时间
阅读量:
阅读量
在Java编程语言中,开发者常借助HashMap类完成对字符串信息的加密与解密操作,所使用的加密机制为基本的字母对应转换方式。
package Unit8;
import java.util.HashMap;
import java.util.Map;
public class Encryption {
static Map<Character,Character> map=new HashMap<Character,Character>();
static Map<Character,Character>map1=new HashMap<Character,Character>();
Encryption(){
String a="abcdefghijklmnopqrstuvwxyz*";
String b="veknohzf*iljxdmygbrcswqupta";
for(int i=0;i<a.length();i++){
map.put(a.charAt(i),b.charAt(i));
map1.put(b.charAt(i),a.charAt(i));
全部评论 (0)
还没有任何评论哟~
