diff --git a/scripts/get-FA-code b/scripts/get-FA-code new file mode 100755 index 0000000..a3d67a3 --- /dev/null +++ b/scripts/get-FA-code @@ -0,0 +1,3 @@ +#!/bin/bash + +sha256sum $1 | awk '{print $1}' | xxd -r -p | base64 | sed 's/+/-/g' | sed 's|/|_|g' | sed 's/=$//' | sed 's/^/FA/' \ No newline at end of file diff --git a/src/main/java/net/trustyuri/file/FileModule.java b/src/main/java/net/trustyuri/file/FileModule.java index 62c77fb..c234293 100644 --- a/src/main/java/net/trustyuri/file/FileModule.java +++ b/src/main/java/net/trustyuri/file/FileModule.java @@ -1,5 +1,6 @@ package net.trustyuri.file; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; @@ -28,7 +29,7 @@ public int getDataPartLength() { @Override public boolean hasCorrectHash(TrustyUriResource r) throws IOException { FileHasher hasher = new FileHasher(); - String ac = hasher.makeArtifactCode(r.getInputStream()); + String ac = hasher.makeArtifactCode(new BufferedInputStream(r.getInputStream())); return r.getArtifactCode().equals(ac); } diff --git a/src/main/java/net/trustyuri/file/ProcessFile.java b/src/main/java/net/trustyuri/file/ProcessFile.java index fb295a8..92296e3 100644 --- a/src/main/java/net/trustyuri/file/ProcessFile.java +++ b/src/main/java/net/trustyuri/file/ProcessFile.java @@ -1,5 +1,6 @@ package net.trustyuri.file; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -15,7 +16,7 @@ public static void main(String[] args) throws IOException { public static void process(File file) throws IOException { String filename = file.getName(); FileHasher hasher = new FileHasher(); - String ac = hasher.makeArtifactCode(new FileInputStream(file)); + String ac = hasher.makeArtifactCode(new BufferedInputStream(new FileInputStream(file))); String ext = ""; String base = filename; if (filename.matches(".+\\.[A-Za-z0-9\\-_]{0,20}")) {