def getCacheKey(self, callargs, unpack=True): if unpack: callargs=self._unpack_callargs(callargs) try: return md5_new(cPickle_dumps(callargs)).hexdigest() except PickleError, pe: raise UnCacheable, pe[0]
def getCacheKey(self, callargs, unpack=True): if unpack: callargs = self._unpack_callargs(callargs) try: return md5_new(cPickle_dumps(callargs)).hexdigest() except PickleError, pe: raise UnCacheable, pe[0]
def hash_password(password,salt): ''' takes password: string, salt: string uses md5 to created hash password return hashed_password: string ''' return md5_new(password+salt).hexdigest()
def signup(): email = request.form["email"] password = request.form["password"] pass_conf = request.form["pass_conf"] first_name = request.form["first_name"] last_name = request.form["last_name"] if len(password) < 8: flash("You password must be greater than 8 characters!") elif password != password: flash("Your passwords do not match!") elif not EMAIL_REGEX.match(email): flash("Not a valid email!") elif len(first_name) < 2: flash("First name must be greater than 2 characters") elif len(last_name) < 2: flash("Last name must be greater than 2 characters") else: query = "INSERT into USERS (email, password, first_name, last_name, created_at, salt) VALUES (:email, :password, :first_name, :last_name, NOW(), :salt)" salt = b2a_hex(urandom(15)) data = { "email": email, "password": md5_new(password + salt).hexdigest(), "salt": salt, "first_name": first_name, "last_name": last_name } mysql.query_db(query,data) session["logged_in"] = True session["current_user"] = email return redirect('/')
def compute(name): """Returns the sum of the file 'name'.""" try: f = file(name, "rb") m = md5_new() line_size = BUFFER_SIZE l = f.read(line_size) while l != '': m.update(l) yield (None, len(l)) l = f.read(line_size) yield (m.hexdigest().upper(), 0) except IOError, e: print e yield ("", 0)
def login(): if request.method == "GET": return render_template('login.html') else: email = request.form["email"] password = request.form["password"] query = "select email, password, salt from users where email = :email" user = mysql.query_db(query,{ "email": email } ) if len(user) == 0: flash("Email was not found!") elif md5_new(password + user[0]["salt"]).hexdigest() == user[0]["password"]: session["current_user"] = email session["logged_in"] = True return render_template('user.html') else: flash("Password incorrect") return redirect('/login')
def storeFeeds(self, url, feeds): """ store all feeds in database """ for feed in feeds: _date = time.localtime() if 'published_parsed' in feed: _date = feed['published_parsed'] date = datetime(_date.tm_year, _date.tm_mon, _date.tm_mday) doc = { '_id': md5_new(feed.id).hexdigest(), 'title': feed.title, 'date': date, 'link': feed.link, 'summary': feed.summary, 'type': url, 'status': 'new', } try: self.feedsCol.insert(doc) except DuplicateKeyError: pass
def get_checksum(self): return md5_new(self.data).digest()
def hash108(s): m = md5_new() m.update(s) return m.hexdigest()[:27]