自己写了个拙劣的加密算法,还望各位看到的朋友勿喷,用于掩盖明文密码,还是够用了。
package com.encryption.demo.utils; public abstract class Encryption { private final static String encryKey[] = { "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Sagittarius", "Capricorn", "Aquarius", "Pisces" }; public static final String encryption(String password) { int startIndex = 0; int pwdLen = password.length(); if (pwdLen < encryKey.length) { startIndex = pwdLen; } char[] pwdArr = password.toCharArray(); StringBuffer encyPwd = new StringBuffer(); for (int i = 0; i < pwdArr.length; i++) { if (startIndex < encryKey.length) { int eachPwdHashCode = (String.valueOf(pwdArr[i])).hashCode(); int eachencryKeyHashCode = encryKey[startIndex].hashCode(); encyPwd.append(Integer.toHexString(eachPwdHashCode)); encyPwd.append(Integer.toHexString(eachencryKeyHashCode)); startIndex++; } else { startIndex = 0; } } return encyPwd.toString(); } }