• R/O
  • SSH
  • HTTPS

o2on: Commit


Commit MetaInfo

Revisão176 (tree)
Hora2009-10-31 00:25:21
Autornawota

Mensagem de Log

bit 計算の高速化。

Mudança Sumário

Diff

--- trunk/opy2on/lib/o2on_node.py (revision 175)
+++ trunk/opy2on/lib/o2on_node.py (revision 176)
@@ -9,7 +9,7 @@
99 import re
1010 import urllib2
1111 import cPickle
12-from struct import unpack, pack
12+from struct import unpack, pack, calcsize
1313 from binascii import unhexlify, hexlify
1414 import httplib
1515 import socket
@@ -56,16 +56,22 @@
5656 regIP = re.compile(r'(\d+)\.(\d+)\.(\d+)\.(\d+)')
5757 m = regIP.match(ip)
5858 if not m: raise Exception
59- return hexlify(aesobj.encrypt(pack("B", int(m.group(1)))+
60- pack("B", int(m.group(2)))+
61- pack("B", int(m.group(3)))+
62- pack("B", int(m.group(4)))+"\x00"*12)[:4])
59+ return hexlify(aesobj.encrypt(pack("4B", int(m.group(1)),
60+ int(m.group(2)), int(m.group(3)),
61+ int(m.group(4)))+"\x00"*12)[:4])
6362
6463 def hash_xor(a,b):
6564 res = ""
66- for i in range(0,len(a)):
67- res += chr(ord(a[i]) ^ ord(b[i]))
68- return res
65+ if(len(a) != 20 or len(b) != 20): raise Exception()
66+ if calcsize("L") == 8 and calcsize("I") == 4:
67+ resa = unpack("2LI", a)
68+ resb = unpack("2LI", b)
69+ return pack("2LI", resa[0] ^ resb[0], resa[1] ^ resb[1], resa[2] ^ resb[2])
70+ elif calcsize("Q") == 8 and calcsize("L") == 4:
71+ resa = unpack("2QL", a)
72+ resb = unpack("2QL", b)
73+ return pack("2QL", resa[0] ^ resb[0], resa[1] ^ resb[1], resa[2] ^ resb[2])
74+ else: raise Exception()
6975
7076 def hash_bittest(x, pos):
7177 return (((ord(x[pos/8]) >> (pos%8)) & 0x01 != 0))
--- trunk/opy2on/lib/o2on_key.py (revision 175)
+++ trunk/opy2on/lib/o2on_key.py (revision 176)
@@ -25,6 +25,8 @@
2525 import o2on_node
2626
2727 def my_replace_handler(inst):
28+ if inst.end-inst.start == 1:
29+ return ((u"\u0000", inst.start+1))
2830 return ((u"\u30fb", inst.start+2))
2931
3032 try:
Show on old repository browser