Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Downloadable:
- def __init__(self, url):
- self.url = url
- class Downloader(Downloadable):
- __store = ''
- __hashed = ''
- __encoded = ''
- def __init__(self, url, hash):
- Downloadable.__init__(self, url)
- def download(self):
- import urllib2
- r = urllib2.urlopen(self.url)
- global __store
- __store = r.read()
- def hash(self):
- m = hashlib.md5()
- m.update(__store)
- global __hashed
- __hashed = m.hexdigest()
- return __hashed
- def encode(self):
- import base64
- global __store
- global __encoded
- __encoded = base64.b64encode(__store)
- return __encoded
- def isValid(self):
- if self.hash != __hashed:
- return False
- else: return True
Add Comment
Please, Sign In to add comment