def __init__(self, configFile): self.config = config = SafeConfigParser() config.read(configFile) host = config.get('server', 'host') port = config.getint('server', 'port') pid = tiger.hash(uuid.uuid1().hex).replace('\x00', '\x01') self.pid = base32.encode(pid) self.cid = base32.encode(tiger.hash(pid)) self.inf = { 'ID': self.cid, 'PD': self.pid, 'SF': 0, # number of shared files 'SS': 1, # size of shared files in bytes 'NI': 'daemon', # nickname 'VE': 'pyadc 0.1', # client version 'US': 0, # maximum upload speed, bytes/second # 'DS': 0, # maximum download speed, bytes/second 'FS': 0, # number of free upload slots 'SL': 0, # maximum number of open slots 'HN': 0, # number of hubs where user is normal 'HR': 0, # number of hubs where user is registered and normal 'HO': 0, # number of hubs where user is op and normal 'SU': 'TCP4', # list of capabilities # 'UDP4' is for UDP, 'ADC0' is for ADCS 'U4': 0, # udp ipv4 port } self.conn = Connection(host, port) self.clients = {} self.info = {} self.connections = [] self.logged_in = False self.handleMap = { 'B': self.handleBroadcast, 'I': self.handleInfo, 'F': self.handleFeature, 'D': self.handleDirect, }
def __init__(self, configFile): self.config = config = SafeConfigParser() config.read(configFile) host = config.get('server', 'host') port = config.getint('server', 'port') pid = tiger.hash(uuid.uuid1().hex).replace('\x00', '\x01') self.pid = base32.encode(pid) self.cid = base32.encode(tiger.hash(pid)) self.inf = { 'ID': self.cid, 'PD': self.pid, 'SF': 0, # number of shared files 'SS': 1, # size of shared files in bytes 'NI': 'daemon', # nickname 'VE': 'pyadc 0.1', # client version 'US': 0, # maximum upload speed, bytes/second # 'DS': 0, # maximum download speed, bytes/second 'FS': 0, # number of free upload slots 'SL': 0, # maximum number of open slots 'HN': 0, # number of hubs where user is normal 'HR': 0, # number of hubs where user is registered and normal 'HO': 0, # number of hubs where user is op and normal 'SU': 'TCP4', # list of capabilities # 'UDP4' is for UDP, 'ADC0' is for ADCS 'U4': 0, # udp ipv4 port } self.conn = Connection(host, port) self.clients = {} self.info = {} self.connections = [] self.logged_in = False self.handleMap = { 'B':self.handleBroadcast, 'I':self.handleInfo, 'F':self.handleFeature, 'D':self.handleDirect, }
def test_tiger_hash(): assert tiger.hash('') == '24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A' assert tiger.hash('abc') == \ 'F258C1E88414AB2A527AB541FFC5B8BF935F7B951C132951' assert tiger.hash('Tiger') == \ '9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF' assert tiger.hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01" \ "23456789+-") == '87FB2A9083851CF7470D2CF810E6DF9EB586445034A5A386' assert tiger.hash("ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+" \ "0123456789") == '467DB80863EBCE488DF1CD1261655DE957896565975F9197' assert tiger.hash("Tiger - A Fast New Hash Function, by Ross Anderson and" \ " Eli Biham") == '0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303' assert tiger.hash("Tiger - A Fast New Hash Function, by Ross Anderson and" \ " Eli Biham, proceedings of Fast Software Encryption 3, Cambridge.")== \ 'EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193' assert tiger.hash("Tiger - A Fast New Hash Function, by Ross Anderson and" \ " Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 19" \ "96.") == '3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC' assert tiger.hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01" \ "23456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345" \ "6789+-") == '00B83EB4E53440C576AC6AAEE0A7485825FD15E70A59FFE4'
def hash_string(string): h = tiger.hash(string) a, b, c = map(list, (h[0:16], h[16:32], h[32:48])) map(lambda s: s.reverse(), (a, b, c)) return (''.join(a+b+c)).lower()
def hash_string(string): h = tiger.hash(string) a, b, c = map(list, (h[0:16], h[16:32], h[32:48])) map(lambda s: s.reverse(), (a, b, c)) return (''.join(a + b + c)).lower()