mirror of
https://e.coding.net/circlecloud/AuthMe.git
synced 2024-12-22 06:48:55 +00:00
格式化加密部分...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
ea4b75a212
commit
36b63958cc
@ -35,7 +35,7 @@ public class PasswordSecurity {
|
||||
method = event.getMethod();
|
||||
|
||||
if (method == null) {
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
throw new NoSuchAlgorithmException("未知的加密算法...");
|
||||
}
|
||||
|
||||
if (method.comparePassword(hash, password, playerName)) {
|
||||
@ -48,7 +48,7 @@ public class PasswordSecurity {
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
throw new NoSuchAlgorithmException("加密算法" + algo.name() + "运行时出现问题...");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class PasswordSecurity {
|
||||
method = null;
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
throw new NoSuchAlgorithmException("加密算法" + alg.name() + "运行时出现问题...");
|
||||
}
|
||||
String salt = "";
|
||||
switch (alg) {
|
||||
@ -150,13 +150,13 @@ public class PasswordSecurity {
|
||||
case CUSTOM:
|
||||
break;
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
throw new NoSuchAlgorithmException("未知的加密算法...");
|
||||
}
|
||||
final PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
method = event.getMethod();
|
||||
if (method == null) {
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
throw new NoSuchAlgorithmException("未知的加密算法...");
|
||||
}
|
||||
return method.getHash(password, salt, playerName);
|
||||
}
|
||||
|
@ -11,27 +11,31 @@ public class RandomString {
|
||||
|
||||
private static final char[] chars = new char[36];
|
||||
|
||||
static {
|
||||
for (int idx = 0; idx < 10; ++idx) {
|
||||
chars[idx] = (char) ('0' + idx);
|
||||
}
|
||||
for (int idx = 10; idx < 36; ++idx) {
|
||||
chars[idx] = (char) ('a' + idx - 10);
|
||||
}
|
||||
}
|
||||
|
||||
private final char[] buf;
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public RandomString(int length) {
|
||||
if (length < 1)
|
||||
throw new IllegalArgumentException("length < 1: " + length);
|
||||
public RandomString(final int length) {
|
||||
if (length < 1) {
|
||||
throw new IllegalArgumentException("随机字符串长度小于1: " + length);
|
||||
}
|
||||
buf = new char[length];
|
||||
random.setSeed(Calendar.getInstance().getTimeInMillis());
|
||||
}
|
||||
|
||||
static {
|
||||
for (int idx = 0; idx < 10; ++idx)
|
||||
chars[idx] = (char) ('0' + idx);
|
||||
for (int idx = 10; idx < 36; ++idx)
|
||||
chars[idx] = (char) ('a' + idx - 10);
|
||||
}
|
||||
|
||||
public String nextString() {
|
||||
for (int idx = 0; idx < buf.length; ++idx)
|
||||
for (int idx = 0; idx < buf.length; ++idx) {
|
||||
buf[idx] = chars[random.nextInt(chars.length)];
|
||||
}
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user