[Java] 纯文本查看 复制代码 public static String encryptWithXor(String str) {
try {
if (TextUtils.isEmpty(str)) {
return null;
}
byte[] bytes = str.getBytes("UTF-8");
for (int i = 0; i < bytes.length; i++) {
bytes = (byte)(bytes ^ 5);
}
return DigestUtils.toHexString(bytes, 0, bytes.length);
} catch (Exception unused) {
return str;
}
}
static final char[] HEX_CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public static String toHexString(byte[] bArr, int i, int i2) {
if (bArr == null) {
return "";
} else {
int i3 = i2 * 2;
char[] cArr = new char[i3];
int i4 = 0;
for (int i5 = 0; i5 < i2; i5++) {
int i6 = bArr[i5 + i] & -1;
int i7 = i4 + 1;
cArr[i4] = HEX_CHARS[i6 >> 4];
i4 = i7 + 1;
cArr[i7] = HEX_CHARS[i6 & 15];
}
return new String(cArr, 0, i3);
}
}
以上是关键参数。求助
补充内容 (2022-5-18 00:20):
明文:123123 密文:343736343736 |