Torrent to Magnet
Javascript implementation of magnet URI conversion
view on
github

Converter

Javascript is required to use the inline converter.
Drop .torrent files here
to convert them to magnet URIs
Or click to open the file browser

Libraries

The following Javascript libraries are used on this page:

They are primarly designed for web usage, but they can be trivially modified to be used with something such as node.js.

sha1.js

Computes the SHA-1 hash of the specified data using the basic algorithm described in RFC 3174, with a paradigm similar to python's hashlib. Data can be input in chunks, and the digest can be calculated at any point without modifying the internal state.

Public interface

The following are public methods on the SHA1 class:

  • constructor()
    Creates a new SHA1 hashing instance.
  • reset()
    Resets the internal state of the instance.
  • update(value_array)
    Update the internal state of the hashing object with the values contained in value_array.
    value_array can be a string, with each character in the range [0,255]; or a (typed) array, with each value in the range [0,255].
  • digest() : Uint8Array
    Computes and returns the SHA1 digest of all the data input so far. The return value is a Uint8Array of length 20.

bencode.js

Encode/decode an object or string using the Bencode format.

Public interface

The following are public methods on the Bencode module:

  • encode(obj) : string
    Encode obj into a Bencoded string.
    obj can only be a string, number, array, or object. Arrays and objects can also only contain the aforementioned types.
  • decode(str) : [object | array | string | number]
    throws "Invalid format"
    Converts Bencoded str back into its original type. If data is malformed, an exception is thrown.

base32.js

Encode/decode a string using the RFC 4648 Base32 format.

Public interface

The following are public methods on the Base32 module:

  • encode(str) : string
    Encode str into Base32.
  • decode(str) : string
    Decode str from Base32 into its original string.

Other Javascript files

These are the other Javascript files included in this repository:

  • sha1.test.js - Test case file similar to the one here
  • t2m.loader.js - The loader file used to set up this page
  • t2m.js - The main file used to process .torrent files on this page