Calculate Torrent Hash from file.
Calculate Torrent Hash from file.
Code:
File file = new File("/file.torrent");
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
InputStream input = null;
try {
input = new FileInputStream(file);
StringBuilder builder = new StringBuilder();
while (!builder.toString().endsWith("4:info")) {
builder.append((char) input.read()); // It's ASCII anyway.
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
for (int data; (data = input.read()) > -1; output.write(data));
sha1.update(output.toByteArray(), 0, output.size() - 1);
} finally {
if (input != null) try { input.close(); } catch (IOException ignore) {}
}
byte[] hash = sha1.digest(); // Here's your hash. Do your thing with it.
can someone help porting it to vb6!
Re: Calculate Torrent Hash from file.
Is that all of it? no references, no other declarations??
Re: Calculate Torrent Hash from file.
yes that looks all of it!!
Re: Calculate Torrent Hash from file.
Looks like .Net code. I'll ask a moderator to move it to the proper section of the forums
Re: Calculate Torrent Hash from file.
It is Java. The OP is asking for a VB6 translation.