mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-29 20:19:06 +00:00
Worlds
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
@@ -116,6 +117,25 @@ public class IO
|
||||
return "¯\\_(ツ)_/¯";
|
||||
}
|
||||
|
||||
public static String hash(File b)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageDigest d = MessageDigest.getInstance("SHA-256");
|
||||
DigestInputStream din = new DigestInputStream(new FileInputStream(b), d);
|
||||
fullTransfer(din, new VoidOutputStream(), 8192);
|
||||
din.close();
|
||||
return bytesToHex(din.getMessageDigest().digest());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "¯\\_(ツ)_/¯";
|
||||
}
|
||||
|
||||
public static String bytesToHex(byte[] bytes)
|
||||
{
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
|
||||
13
src/main/java/com/volmit/iris/util/VoidOutputStream.java
Normal file
13
src/main/java/com/volmit/iris/util/VoidOutputStream.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class VoidOutputStream extends OutputStream
|
||||
{
|
||||
@Override
|
||||
public void write(int b) throws IOException
|
||||
{
|
||||
// poof
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user