Guest User

Untitled

a guest
Dec 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. class Downloadable:
  2.     def __init__(self, url):
  3.         self.url = url
  4. class Downloader(Downloadable):
  5.         __store = ''
  6.         __hashed = ''
  7.         __encoded = ''
  8.         def __init__(self, url, hash):
  9.                 Downloadable.__init__(self, url)
  10.         def download(self):
  11.                 import urllib2
  12.                 r = urllib2.urlopen(self.url)
  13.                 global __store
  14.                 __store = r.read()
  15.         def hash(self):
  16.                 m = hashlib.md5()
  17.                 m.update(__store)
  18.                 global __hashed
  19.                 __hashed = m.hexdigest()
  20.                 return __hashed
  21.         def encode(self):
  22.                 import base64
  23.                 global __store
  24.                 global __encoded
  25.                 __encoded = base64.b64encode(__store)
  26.                 return __encoded
  27.         def isValid(self):
  28.                 if self.hash != __hashed:
  29.                         return False
  30.                 else: return True
Add Comment
Please, Sign In to add comment