SteamWar/SpigotCore
Archiviert
13
0

Changing downloadlink-generator

Dieser Commit ist enthalten in:
Lixfel 2019-12-16 20:32:57 +01:00
Ursprung 3ed64a8b60
Commit 7e070be9d9

Datei anzeigen

@ -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;
}