"""
from datetime import datetime
-import os, sha, random
+import os, hashlib, random
from twisted.internet import defer, reactor
from twisted.internet.abstract import isIPAddress
def store_values(self, result):
self.stored = 3
- d = self.a.storeValue(sha.new('4045').digest(), str(4045*3))
+ d = self.a.storeValue(hashlib.sha1('4045').digest(), str(4045*3))
d.addCallback(self.value_stored, 4045)
- d = self.a.storeValue(sha.new('4044').digest(), str(4044*2))
+ d = self.a.storeValue(hashlib.sha1('4044').digest(), str(4044*2))
d.addCallback(self.value_stored, 4044)
- d = self.b.storeValue(sha.new('4045').digest(), str(4045*2))
+ d = self.b.storeValue(hashlib.sha1('4045').digest(), str(4045*2))
d.addCallback(self.value_stored, 4045)
def check_values(self, result, values):
def get_values(self):
self.checked = 4
- d = self.a.getValue(sha.new('4044').digest())
+ d = self.a.getValue(hashlib.sha1('4044').digest())
d.addCallback(self.check_values, [str(4044*2)])
- d = self.b.getValue(sha.new('4044').digest())
+ d = self.b.getValue(hashlib.sha1('4044').digest())
d.addCallback(self.check_values, [str(4044*2)])
- d = self.a.getValue(sha.new('4045').digest())
+ d = self.a.getValue(hashlib.sha1('4045').digest())
d.addCallback(self.check_values, [str(4045*2), str(4045*3)])
- d = self.b.getValue(sha.new('4045').digest())
+ d = self.b.getValue(hashlib.sha1('4045').digest())
d.addCallback(self.check_values, [str(4045*2), str(4045*3)])
def test_store(self):
if i == len(self.l):
self.get_values()
else:
- d = self.l[j].storeValue(sha.new(str(self.startport+i)).digest(), str((self.startport+i)*(j+1)))
+ d = self.l[j].storeValue(hashlib.sha1(str(self.startport+i)).digest(), str((self.startport+i)*(j+1)))
d.addCallback(self.store_values, i, j+1)
def get_values(self, result = None, check = None, i = 0, j = 0):
if i == len(self.l):
self.lastDefer.callback(1)
else:
- d = self.l[i].getValue(sha.new(str(self.startport+j)).digest())
+ d = self.l[i].getValue(hashlib.sha1(str(self.startport+j)).digest())
check = []
for k in range(self.startport+j, (self.startport+j)*(j+1)+1, self.startport+j):
check.append(str(k))