自分の12星座の暗号化のアルゴリズム
3020 ワード
自分で拙劣な暗号化アルゴリズムを書いて、また各位の見た友达が噴き出さないでくださいを望んで、明文のパスワードを隠すために、やはり十分です.
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();
}
}