diff --git a/core/src/main/groovy/com/muwire/core/files/FileHasher.groovy b/core/src/main/groovy/com/muwire/core/files/FileHasher.groovy index ef4d3723..451c4378 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileHasher.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileHasher.groovy @@ -67,4 +67,18 @@ class FileHasher { byte [] hashList = output.toByteArray() InfoHash.fromHashList(hashList) } + + public static void main(String[] args) { + if (args.length != 1) { + println "This utility computes an infohash of a file" + println "Pass absolute path to a file as an argument" + System.exit(1) + } + + def file = new File(args[0]) + file = file.getAbsoluteFile() + def hasher = new FileHasher() + def infohash = hasher.hashFile(file) + println infohash + } }