Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Generowanie magnet linku
k00sl
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 20.04.2009

Ostrzeżenie: (0%)
-----


Witam serdecznie,

Od pewnego czasu próbuję stworzyć generatora magnet linków. Tak jak tutaj: http://centrump2p.com/magnet/


Przykładowo posiadam taki info_hash:

8905762b8851be015260b72d92b34cf55bcdb254 // 40 znaków

Po generatorze centrump2p.com wygląda on tak:

RECXMK4IKG7ACUTAW4WZFM2M6VN43MSU // 32 znaki


Dokumentacje:

vuze.com ( http://wiki.vuze.com/w/Magnet_link ):
The magnet link consists of the prefix magnet:?xt=urn:btih: and the base32() encoded SHA1 of the torrent's info dictionary (known as torrent-hash or infohash). Please note that's the base32-encoding of the torrent-hash's binary (20byte) representation, not the hexadecimal representation.

bittorrent.org ( http://bittorrent.org/beps/bep_0009.html ):
Is the info-hash hex encoded, for a total of 40 characters. For compatability with existing links in the wild, clients should also support the 32 character base32 [1] encoded info-hash.


Próbuję w ten sposób


magnet.php
  1. <?php
  2.  
  3. include('class.base32.php5');
  4.  
  5. $info_hash = '8905762b8851be015260b72d92b34cf55bcdb254';
  6.  
  7. $b = new Base32(Base32::csRFC3548);
  8. print $b->fromString($info_hash);
  9.  
  10. ?>


Klasa base32 znajduję się tutaj: http://fremnet.net/article/215/class-base32


No i niestety wygląda to tak, że otrzymuję 64 znakowy ciąg (powinien być 32):

HA4TANJXGYZGEOBYGUYWEZJQGE2TENRQMI3TEZBZGJRDGNDDMY2TKYTDMRRDENJU


Bardzo proszę o pomoc przy tym kodowaniu,

Pozdrawiam.
Go to the top of the page
+Quote Post
Noidea
post
Post #2





Grupa: Zarejestrowani
Postów: 226
Pomógł: 61
Dołączył: 20.08.2010

Ostrzeżenie: (0%)
-----


Sam sobie odpowiedziałeś wklejając kawałek dokumentacji (IMG:style_emoticons/default/smile.gif)
Cytat
Please note that's the base32-encoding of the torrent-hash's binary (20byte) representation, not the hexadecimal representation.



  1. <?php
  2.  
  3. include( 'class.base32.php5' );
  4.  
  5. $info_hash = pack( 'H*', '8905762b8851be015260b72d92b34cf55bcdb254' );
  6.  
  7. $b = new Base32( Base32::csRFC3548 );
  8. print $b->fromString( $info_hash );
  9.  
  10. ?>
Go to the top of the page
+Quote Post
k00sl
post
Post #3





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 20.04.2009

Ostrzeżenie: (0%)
-----


oto właśnie chodziło, dziękuję
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 17:40