Move libs to top level
This commit is contained in:
parent
87ce108bd1
commit
57f46b2210
212 changed files with 16 additions and 29 deletions
|
|
@ -0,0 +1,26 @@
|
|||
package love.distributedrebirth.warpme.hash;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class WaterShot {
|
||||
|
||||
private List<WaterSoftHash> softHashes = new ArrayList<>();
|
||||
|
||||
public List<WaterSoftHash> getSoftHashes() {
|
||||
return softHashes;
|
||||
}
|
||||
|
||||
public void setSoftHashes(List<WaterSoftHash> shotHashes) {
|
||||
for (WaterSoftHash hash:shotHashes) {
|
||||
addSoftHash(hash);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSoftHash(WaterSoftHash softHash) {
|
||||
this.softHashes.add(softHash);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package love.distributedrebirth.warpme.hash;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.x4o.xml.io.X4OConnectionException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
import love.distributedrebirth.warpme.Warpᵐᵉ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class WaterShotAddict {
|
||||
|
||||
public boolean validateWarpChainLink(File folder) throws FileNotFoundException, X4OConnectionException, SAXException, IOException, NoSuchAlgorithmException {
|
||||
File fileWarpHash = new File(folder, Warpᵐᵉ.WARP_HASH);
|
||||
if (!fileWarpHash.exists()) {
|
||||
return false;
|
||||
}
|
||||
WaterShot waterShot = WaterShotDriver.newInstance().createReader().readFile(fileWarpHash);
|
||||
for (WaterSoftHash hash:waterShot.getSoftHashes()) {
|
||||
File checkFile = new File(folder, hash.getFile());
|
||||
if (!checkFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
String fileHex = calcHashInHex(checkFile);
|
||||
if (!fileHex.equals(hash.getHex())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateWarpHashes(File folder) throws FileNotFoundException, X4OConnectionException, SAXException, IOException, NoSuchAlgorithmException {
|
||||
File fileWarpHash = new File(folder, Warpᵐᵉ.WARP_HASH);
|
||||
WaterShot waterShot = WaterShotDriver.newInstance().createReader().readFile(fileWarpHash);
|
||||
for (WaterSoftHash hash:waterShot.getSoftHashes()) {
|
||||
hash.setHex(calcHashInHex(new File(folder, hash.getFile())));
|
||||
}
|
||||
WaterShotDriver.newInstance().createWriter().writeFile(waterShot, fileWarpHash);
|
||||
}
|
||||
|
||||
private String calcHashInHex(File file) throws IOException, NoSuchAlgorithmException {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] bytes = Files.readAllBytes(file.toPath());
|
||||
byte[] encodedhash = digest.digest(bytes);
|
||||
return bytesToHex(encodedhash);
|
||||
}
|
||||
|
||||
private String bytesToHex(byte[] hash) {
|
||||
StringBuilder hexString = new StringBuilder(2 * hash.length);
|
||||
for (int i = 0; i < hash.length; i++) {
|
||||
String hex = Integer.toHexString(0xff & hash[i]);
|
||||
if(hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package love.distributedrebirth.warpme.hash;
|
||||
|
||||
import org.x4o.xml.X4ODriver;
|
||||
import org.x4o.xml.X4ODriverManager;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class WaterShotDriver extends X4ODriver<WaterShot> {
|
||||
|
||||
static final public String LANGUAGE_NAME = "warp-hash";
|
||||
static final public String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
||||
|
||||
@Override
|
||||
public String getLanguageName() {
|
||||
return LANGUAGE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLanguageVersions() {
|
||||
return LANGUAGE_VERSIONS;
|
||||
}
|
||||
|
||||
static public WaterShotDriver newInstance() {
|
||||
return (WaterShotDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package love.distributedrebirth.warpme.hash;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class WaterSoftHash {
|
||||
|
||||
private String file;
|
||||
private String hex;
|
||||
|
||||
public WaterSoftHash() {
|
||||
}
|
||||
|
||||
public WaterSoftHash(String file, String hex) {
|
||||
setFile(file);
|
||||
setHex(hex);
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getHex() {
|
||||
return hex;
|
||||
}
|
||||
|
||||
public void setHex(String hex) {
|
||||
this.hex = hex;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue