Open Fuzion24 opened 9 years ago
looked into this a bit further
sha256.groovy
:
import java.security.MessageDigest
public class HelloWorld {
public static main(args){
if (args.size() < 0){
println("Usage: groovy <script> <file-to-hash>")
return;
}
println(calculateSha256(new File(args[0])))
}
static String calculateSha256(file) {
MessageDigest md = MessageDigest.getInstance("SHA-256");
file.eachByte 4096, {bytes, size ->
md.update(bytes, 0, size);
}
return md.digest().collect {String.format "%02x", it}.join();
}
}
It does appear that the sha256 is correct, maybe i was attempting to hash different jar files than what groovy was in the plugin:
➜ Downloads groovy sha256.groovy ./209-timothy-c-may-the-cyphernomicon.pdf
a257016a9ddb41b24726bbafc5d3424d837218b6a11829587886b999727a2f1d
➜ Downloads shasum -a 256 209-timothy-c-may-the-cyphernomicon.pdf
a257016a9ddb41b24726bbafc5d3424d837218b6a11829587886b999727a2f1d 209-timothy-c-may-the-cyphernomicon.pdf
This is a really nice idea here! However, it seems that the sha256 calculation performed by the plugin is different than want I'm getting from OSX's shasum tool