加密算法(自己写)java自己给明文密码加密

来源:互联网 发布:怎么免费开淘宝店 编辑:程序博客网 时间:2024/06/07 01:15

1.创建加密字典

public static Map<String, String> getEncryptMapData() {    Map<String, String> map = new HashMap<String, String>();    map.put("0", "a");    map.put("1", "b");    map.put("2", "c");    map.put("3", "d");    map.put("4", "e");    map.put("5", "f");    map.put("6", "g");    map.put("7", "h");    map.put("8", "i");    map.put("9", "j");    return map;}2.加密算法
private static String encryptPassword(String password) {        String name = "";    for (int i = 0; i < password.length(); i++) {        name = name + getEncryptMapData().get(String.valueOf(password.charAt(i)));    }    return name;}
3.调用测试
public static void main(String[] args) {    System.out.println(encryptPassword("123456"));}
4.输出结果
bcdef

阅读全文
1 0
原创粉丝点击