mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 21:06:16 +00:00
fix: update nbot hashing
This commit is contained in:
parent
1193bd0bb4
commit
92867a6217
1 changed files with 13 additions and 9 deletions
|
|
@ -11,7 +11,6 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
|||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
|
@ -159,18 +158,23 @@ public class BotValidationUtilities {
|
|||
try {
|
||||
String[] arguments = command.split(" ");
|
||||
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
String time = String.valueOf(System.currentTimeMillis() / 5_000);
|
||||
String input = arguments[0].replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + time + ";" + key;
|
||||
final long time = Math.floorDiv(System.currentTimeMillis(), 250);
|
||||
|
||||
md.update(input.getBytes(StandardCharsets.UTF_8));
|
||||
// yep it is very raw code indeed.
|
||||
final String input = "ThisCodeIsRaw;" + client.player.getUuidAsString() + ";" + time + ";" + key;
|
||||
|
||||
byte[] hash = md.digest();
|
||||
final byte[] digest = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
final byte[] positiveDigest = new byte[digest.length + 1];
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.wrap(hash, 0, 4);
|
||||
long bigInt = (buffer.getInt() & 0xFFFFFFFFL);;
|
||||
String stringHash = Long.toString(bigInt, 36);
|
||||
System.arraycopy(digest, 0, positiveDigest, 1, digest.length);
|
||||
|
||||
final BigInteger bi = new BigInteger(positiveDigest);
|
||||
|
||||
final String b36 = bi.toString(36);
|
||||
|
||||
final String stringHash = b36.length() > 16 ? b36.substring(0, 16) : b36;
|
||||
|
||||
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue