mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] MojangCoreProvider
This commit is contained in:
parent
aa9b84ba4a
commit
902f09324b
2 changed files with 16 additions and 4 deletions
|
@ -11,8 +11,8 @@
|
|||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Texture extends StreamObject {
|
||||
private static final SecurityHelper.DigestAlgorithm DIGEST_ALGO = SecurityHelper.DigestAlgorithm.SHA256;
|
||||
|
@ -55,20 +55,20 @@ public Texture(String url, Path local, boolean cloak) throws IOException {
|
|||
try (InputStream input = IOHelper.newInput(local)) {
|
||||
IOHelper.readTexture(input, cloak); // Verify texture
|
||||
}
|
||||
this.digest = Objects.requireNonNull(SecurityHelper.digest(DIGEST_ALGO, local), "digest");
|
||||
this.digest = SecurityHelper.digest(DIGEST_ALGO, local);
|
||||
this.metadata = null;
|
||||
}
|
||||
|
||||
|
||||
public Texture(String url, byte[] digest) {
|
||||
this.url = IOHelper.verifyURL(url);
|
||||
this.digest = Objects.requireNonNull(digest, "digest");
|
||||
this.digest = digest == null ? new byte[0] : digest;
|
||||
this.metadata = null;
|
||||
}
|
||||
|
||||
public Texture(String url, byte[] digest, Map<String, String> metadata) {
|
||||
this.url = url;
|
||||
this.digest = digest;
|
||||
this.digest = digest == null ? new byte[0] : digest;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
|
@ -77,4 +77,13 @@ public void write(HOutput output) throws IOException {
|
|||
output.writeASCII(url, 2048);
|
||||
output.writeByteArray(digest, -DIGEST_ALGO.bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Texture{" +
|
||||
"url='" + url + '\'' +
|
||||
", digest=" + Arrays.toString(digest) +
|
||||
", metadata=" + metadata +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,6 +394,9 @@ public static byte[] sign(byte[] bytes, ECPrivateKey privateKey) {
|
|||
|
||||
|
||||
public static String toHex(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
int offset = 0;
|
||||
char[] hex = new char[bytes.length << 1];
|
||||
for (byte currentByte : bytes) {
|
||||
|
|
Loading…
Reference in a new issue