~ubuntu-branches/ubuntu/trusty/bittornado/trusty-proposed

« back to all changes in this revision

Viewing changes to BitTornado/BT1/Encrypter.py

  • Committer: Bazaar Package Importer
  • Author(s): Cameron Dale
  • Date: 2010-03-21 14:36:30 UTC
  • Revision ID: james.westby@ubuntu.com-20100321143630-d1zk1zdasaf8125s
Tags: 0.3.18-10
* New patch from upstream's CVS to allow torrents that only have an
  announce list: 30_announce_list_only_torrents.dpatch (Closes: #551766)
* Fix a lot of lintian warnings
  - Update standards version to 3.8.4 (no changes)
* Fix for when compact_reqd is turned off:
  31_fix_for_compact_reqd_off.dpatch (Closes: #574860)
* Switch to the new "3.0 (quilt)" source format

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
def tobinary16(i):
29
29
    return chr((i >> 8) & 0xFF) + chr(i & 0xFF)
30
30
 
31
 
hexchars = '0123456789ABCDEF'
32
 
hexmap = []
33
 
for i in xrange(256):
34
 
    hexmap.append(hexchars[(i&0xF0)/16]+hexchars[i&0x0F])
35
 
 
36
 
def tohex(s):
37
 
    r = []
38
 
    for c in s:
39
 
        r.append(hexmap[ord(c)])
40
 
    return ''.join(r)
41
 
 
42
31
def make_readable(s):
43
32
    if not s:
44
33
        return ''
45
34
    if quote(s).find('%') >= 0:
46
 
        return tohex(s)
 
35
        return b2a_hex(s).upper()
47
36
    return '"'+s+'"'
48
37
   
49
38
 
102
91
            else:
103
92
                self.encrypted = False
104
93
                self.options = options
105
 
                self.write(self.Encoder.my_id)
 
94
                self.write(chr(len(protocol_name)) + protocol_name +
 
95
                    option_pattern + 
 
96
                    self.Encoder.download_id + self.Encoder.my_id )
106
97
                self.next_len, self.next_func = 20, self.read_peer_id
107
98
        else:
108
99
            self.encrypted = None       # don't know yet