Changing downloadlink-generator
Dieser Commit ist enthalten in:
Ursprung
3ed64a8b60
Commit
7e070be9d9
@ -1,7 +1,8 @@
|
||||
package de.steamwar.sql;
|
||||
|
||||
import org.bukkit.craftbukkit.libs.org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
@ -20,7 +21,15 @@ public class DownloadSchematic {
|
||||
throw new SecurityException("Could not check schematic for existance", e);
|
||||
}
|
||||
|
||||
String hash = DigestUtils.sha1Hex(Instant.now().toString() + schem.getSchemOwner() + schem.getSchemID());
|
||||
MessageDigest cript;
|
||||
try {
|
||||
cript = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
cript.reset();
|
||||
cript.update((Instant.now().toString() + schem.getSchemOwner() + schem.getSchemID()).getBytes());
|
||||
String hash = DatatypeConverter.printHexBinary(cript.digest());
|
||||
SQL.update("INSERT INTO SchemDownload (SchemID, Link) VALUES (" + schem.getSchemID() + ", '" + hash + "')");
|
||||
return BASE + hash;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren