Results 1 to 5 of 5

Thread: Calculate Torrent Hash from file.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    84

    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!

  2. #2
    Member
    Join Date
    Sep 2005
    Posts
    44

    Re: Calculate Torrent Hash from file.

    Is that all of it? no references, no other declarations??

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    84

    Re: Calculate Torrent Hash from file.

    yes that looks all of it!!

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Calculate Torrent Hash from file.

    It is Java. The OP is asking for a VB6 translation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width