Replace all '/' in path to File.separator - Code Refactor
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -7,14 +7,12 @@ import java.security.NoSuchAlgorithmException;
|
||||
public class CRAZYCRYPT1 implements EncryptionMethod {
|
||||
|
||||
protected final Charset charset = Charset.forName("UTF-8");
|
||||
private static final char[] CRYPTCHARS = new char[] { '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
private static final char[] CRYPTCHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name
|
||||
+ "__+IÄIH§%NK " + password;
|
||||
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
|
||||
try {
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
md.update(text.getBytes(charset), 0, text.length());
|
||||
|
||||
@@ -11,8 +11,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$10000$" + salt + "$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII",
|
||||
salt.getBytes(), 10000);
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
|
||||
return result + engine.deriveKey(password, 64).toString();
|
||||
@@ -24,8 +23,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
String[] line = hash.split("\\$");
|
||||
String salt = line[2];
|
||||
String derivedKey = line[3];
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII",
|
||||
salt.getBytes(), 10000, derivedKey.getBytes());
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000, derivedKey.getBytes());
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
return engine.verifyKey(password);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ public class IPB3 implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt, playerName));
|
||||
}
|
||||
|
||||
@@ -28,7 +27,6 @@ public class IPB3 implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class JOOMLA implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class MD5 implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ public class MD5VB implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ public class MYBB implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt, playerName));
|
||||
}
|
||||
|
||||
@@ -28,7 +27,6 @@ public class MYBB implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
* @author stefano
|
||||
*/
|
||||
public class PHPBB implements EncryptionMethod {
|
||||
|
||||
private static final int PHP_VERSION = 4;
|
||||
private String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
@@ -29,9 +30,9 @@ public class PHPBB implements EncryptionMethod {
|
||||
}
|
||||
random = random.substring(0, count);
|
||||
}
|
||||
String hash = _hash_crypt_private(password,
|
||||
_hash_gensalt_private(random, itoa64));
|
||||
if (hash.length() == 34) return hash;
|
||||
String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
|
||||
if (hash.length() == 34)
|
||||
return hash;
|
||||
return md5(password);
|
||||
}
|
||||
|
||||
@@ -46,8 +47,7 @@ public class PHPBB implements EncryptionMethod {
|
||||
iteration_count_log2 = 8;
|
||||
}
|
||||
String output = "$H$";
|
||||
output += itoa64.charAt(Math.min(iteration_count_log2
|
||||
+ ((PHP_VERSION >= 5) ? 5 : 3), 30));
|
||||
output += itoa64.charAt(Math.min(iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30));
|
||||
output += _hash_encode64(input, 6);
|
||||
return output;
|
||||
}
|
||||
@@ -61,12 +61,16 @@ public class PHPBB implements EncryptionMethod {
|
||||
do {
|
||||
int value = input.charAt(i++);
|
||||
output += itoa64.charAt(value & 0x3f);
|
||||
if (i < count) value |= input.charAt(i) << 8;
|
||||
if (i < count)
|
||||
value |= input.charAt(i) << 8;
|
||||
output += itoa64.charAt((value >> 6) & 0x3f);
|
||||
if (i++ >= count) break;
|
||||
if (i < count) value |= input.charAt(i) << 16;
|
||||
if (i++ >= count)
|
||||
break;
|
||||
if (i < count)
|
||||
value |= input.charAt(i) << 16;
|
||||
output += itoa64.charAt((value >> 12) & 0x3f);
|
||||
if (i++ >= count) break;
|
||||
if (i++ >= count)
|
||||
break;
|
||||
output += itoa64.charAt((value >> 18) & 0x3f);
|
||||
} while (i < count);
|
||||
return output;
|
||||
@@ -74,12 +78,15 @@ public class PHPBB implements EncryptionMethod {
|
||||
|
||||
String _hash_crypt_private(String password, String setting) {
|
||||
String output = "*";
|
||||
if (!setting.substring(0, 3).equals("$H$")) return output;
|
||||
if (!setting.substring(0, 3).equals("$H$"))
|
||||
return output;
|
||||
int count_log2 = itoa64.indexOf(setting.charAt(3));
|
||||
if (count_log2 < 7 || count_log2 > 30) return output;
|
||||
if (count_log2 < 7 || count_log2 > 30)
|
||||
return output;
|
||||
int count = 1 << count_log2;
|
||||
String salt = setting.substring(4, 12);
|
||||
if (salt.length() != 8) return output;
|
||||
if (salt.length() != 8)
|
||||
return output;
|
||||
String m1 = md5(salt + password);
|
||||
String hash = pack(m1);
|
||||
do {
|
||||
@@ -91,8 +98,8 @@ public class PHPBB implements EncryptionMethod {
|
||||
}
|
||||
|
||||
public boolean phpbb_check_hash(String password, String hash) {
|
||||
if (hash.length() == 34) return _hash_crypt_private(password, hash)
|
||||
.equals(hash);
|
||||
if (hash.length() == 34)
|
||||
return _hash_crypt_private(password, hash).equals(hash);
|
||||
else return md5(password).equals(hash);
|
||||
}
|
||||
|
||||
@@ -110,9 +117,11 @@ public class PHPBB implements EncryptionMethod {
|
||||
}
|
||||
|
||||
static int hexToInt(char ch) {
|
||||
if (ch >= '0' && ch <= '9') return ch - '0';
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return ch - '0';
|
||||
ch = Character.toUpperCase(ch);
|
||||
if (ch >= 'A' && ch <= 'F') return ch - 'A' + 0xA;
|
||||
if (ch >= 'A' && ch <= 'F')
|
||||
return ch - 'A' + 0xA;
|
||||
throw new IllegalArgumentException("Not a hex character: " + ch);
|
||||
}
|
||||
|
||||
@@ -120,7 +129,8 @@ public class PHPBB implements EncryptionMethod {
|
||||
StringBuffer r = new StringBuffer(32);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
String x = Integer.toHexString(bytes[i] & 0xff);
|
||||
if (x.length() < 2) r.append("0");
|
||||
if (x.length() < 2)
|
||||
r.append("0");
|
||||
r.append(x);
|
||||
}
|
||||
return r.toString();
|
||||
|
||||
@@ -20,8 +20,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
String algo = "HmacSHA256";
|
||||
String keyString = getSHA1(salt);
|
||||
try {
|
||||
SecretKeySpec key = new SecretKeySpec(
|
||||
(keyString).getBytes("UTF-8"), algo);
|
||||
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
|
||||
Mac mac = Mac.getInstance(algo);
|
||||
mac.init(key);
|
||||
byte[] bytes = mac.doFinal(password.getBytes("ASCII"));
|
||||
@@ -44,8 +43,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt, ""));
|
||||
}
|
||||
|
||||
@@ -55,8 +53,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ public class ROYALAUTH implements EncryptionMethod {
|
||||
byte byteData[] = md.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte aByteData : byteData)
|
||||
sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16)
|
||||
.substring(1));
|
||||
sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ public class SALTED2MD5 implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getMD5(getMD5(password) + salt));
|
||||
}
|
||||
|
||||
@@ -28,7 +27,6 @@ public class SALTED2MD5 implements EncryptionMethod {
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ public class SHA1 implements EncryptionMethod {
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ public class SHA256 implements EncryptionMethod {
|
||||
sha256.reset();
|
||||
sha256.update(message.getBytes());
|
||||
byte[] digest = sha256.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class SHA512 implements EncryptionMethod {
|
||||
sha512.reset();
|
||||
sha512.update(message.getBytes());
|
||||
byte[] digest = sha512.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class SMF implements EncryptionMethod {
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ public class WBB3 implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt, ""));
|
||||
}
|
||||
|
||||
@@ -28,7 +27,6 @@ public class WBB3 implements EncryptionMethod {
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
|
||||
1, digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,22 +84,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
/**
|
||||
* The substitution box.
|
||||
*/
|
||||
private static final String sbox = "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152"
|
||||
+ "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57"
|
||||
+ "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85"
|
||||
+ "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8"
|
||||
+ "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333"
|
||||
+ "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0"
|
||||
+ "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE"
|
||||
+ "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d"
|
||||
+ "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF"
|
||||
+ "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A"
|
||||
+ "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c"
|
||||
+ "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04"
|
||||
+ "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB"
|
||||
+ "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9"
|
||||
+ "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1"
|
||||
+ "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
|
||||
private static final String sbox = "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152" + "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57" + "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85" + "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8" + "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333" + "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0" + "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE" + "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d" + "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF" + "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A" + "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c" + "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04" + "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB" + "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9" + "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1" + "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
|
||||
|
||||
private static long[][] C = new long[8][256];
|
||||
private static long[] rc = new long[R + 1];
|
||||
@@ -126,8 +111,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
* build the circulant table C[0][x] = S[x].[1, 1, 4, 1, 8, 5, 2,
|
||||
* 9]:
|
||||
*/
|
||||
C[0][x] = (v1 << 56) | (v1 << 48) | (v4 << 40) | (v1 << 32)
|
||||
| (v8 << 24) | (v5 << 16) | (v2 << 8) | (v9);
|
||||
C[0][x] = (v1 << 56) | (v1 << 48) | (v4 << 40) | (v1 << 32) | (v8 << 24) | (v5 << 16) | (v2 << 8) | (v9);
|
||||
/*
|
||||
* build the remaining circulant tables C[t][x] = C[0][x] rotr t
|
||||
*/
|
||||
@@ -144,14 +128,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
*/
|
||||
for (int r = 1; r <= R; r++) {
|
||||
int i = 8 * (r - 1);
|
||||
rc[r] = (C[0][i] & 0xff00000000000000L)
|
||||
^ (C[1][i + 1] & 0x00ff000000000000L)
|
||||
^ (C[2][i + 2] & 0x0000ff0000000000L)
|
||||
^ (C[3][i + 3] & 0x000000ff00000000L)
|
||||
^ (C[4][i + 4] & 0x00000000ff000000L)
|
||||
^ (C[5][i + 5] & 0x0000000000ff0000L)
|
||||
^ (C[6][i + 6] & 0x000000000000ff00L)
|
||||
^ (C[7][i + 7] & 0x00000000000000ffL);
|
||||
rc[r] = (C[0][i] & 0xff00000000000000L) ^ (C[1][i + 1] & 0x00ff000000000000L) ^ (C[2][i + 2] & 0x0000ff0000000000L) ^ (C[3][i + 3] & 0x000000ff00000000L) ^ (C[4][i + 4] & 0x00000000ff000000L) ^ (C[5][i + 5] & 0x0000000000ff0000L) ^ (C[6][i + 6] & 0x000000000000ff00L) ^ (C[7][i + 7] & 0x00000000000000ffL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,14 +172,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
* map the buffer to a block:
|
||||
*/
|
||||
for (int i = 0, j = 0; i < 8; i++, j += 8) {
|
||||
block[i] = (((long) buffer[j]) << 56)
|
||||
^ (((long) buffer[j + 1] & 0xffL) << 48)
|
||||
^ (((long) buffer[j + 2] & 0xffL) << 40)
|
||||
^ (((long) buffer[j + 3] & 0xffL) << 32)
|
||||
^ (((long) buffer[j + 4] & 0xffL) << 24)
|
||||
^ (((long) buffer[j + 5] & 0xffL) << 16)
|
||||
^ (((long) buffer[j + 6] & 0xffL) << 8)
|
||||
^ (((long) buffer[j + 7] & 0xffL));
|
||||
block[i] = (((long) buffer[j]) << 56) ^ (((long) buffer[j + 1] & 0xffL) << 48) ^ (((long) buffer[j + 2] & 0xffL) << 40) ^ (((long) buffer[j + 3] & 0xffL) << 32) ^ (((long) buffer[j + 4] & 0xffL) << 24) ^ (((long) buffer[j + 5] & 0xffL) << 16) ^ (((long) buffer[j + 6] & 0xffL) << 8) ^ (((long) buffer[j + 7] & 0xffL));
|
||||
}
|
||||
/*
|
||||
* compute and apply K^0 to the cipher state:
|
||||
@@ -294,8 +264,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
while (sourceBits > 8) { // at least source[sourcePos] and
|
||||
// source[sourcePos+1] contain data.
|
||||
// take a byte from the source:
|
||||
b = ((source[sourcePos] << sourceGap) & 0xff)
|
||||
| ((source[sourcePos + 1] & 0xff) >>> (8 - sourceGap));
|
||||
b = ((source[sourcePos] << sourceGap) & 0xff) | ((source[sourcePos + 1] & 0xff) >>> (8 - sourceGap));
|
||||
if (b < 0 || b >= 256) {
|
||||
throw new RuntimeException("LOGIC ERROR");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WORDPRESS implements EncryptionMethod {
|
||||
|
||||
private static String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private int iterationCountLog2 = 8;
|
||||
private SecureRandom randomGen = new SecureRandom();
|
||||
@@ -47,8 +48,7 @@ public class WORDPRESS implements EncryptionMethod {
|
||||
|
||||
private String crypt(String password, String setting) {
|
||||
String output = "*0";
|
||||
if (((setting.length() < 2) ? setting : setting.substring(0, 2))
|
||||
.equalsIgnoreCase(output)) {
|
||||
if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) {
|
||||
output = "*1";
|
||||
}
|
||||
String id = (setting.length() < 3) ? setting : setting.substring(0, 3);
|
||||
@@ -95,8 +95,7 @@ public class WORDPRESS implements EncryptionMethod {
|
||||
try {
|
||||
return string.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This system doesn't support UTF-8!", e);
|
||||
throw new UnsupportedOperationException("This system doesn't support UTF-8!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,14 @@ public class XAUTH implements EncryptionMethod {
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
String hash = getWhirlpool(salt + password).toLowerCase();
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1
|
||||
: password.length());
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1
|
||||
: password.length());
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
String salt = hash.substring(saltPos, saltPos + 12);
|
||||
return hash.equals(getHash(password, salt, ""));
|
||||
}
|
||||
|
||||
@@ -14,17 +14,14 @@ public class XF implements EncryptionMethod {
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA256(getSHA256(password)
|
||||
+ regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName)
|
||||
.getSalt();
|
||||
return hash
|
||||
.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
|
||||
}
|
||||
|
||||
public String getSHA256(String password) throws NoSuchAlgorithmException {
|
||||
@@ -33,8 +30,7 @@ public class XF implements EncryptionMethod {
|
||||
byte byteData[] = md.digest();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (byte element : byteData) {
|
||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(
|
||||
1));
|
||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (byte element : byteData) {
|
||||
|
||||
Reference in New Issue
Block a user