def setUp(self): self.musician_tuple = ( ("Chris Squire", "bass", "*****@*****.**"), ("Bill Bruford", "drums", "*****@*****.**"), ("Steve Howe", "guitar", "*****@*****.**"), ("Geddy Lee", "bass", "*****@*****.**"), ("Neil Peart", "drums", "*****@*****.**"), ("Alex Lifeson", "guitar", "*****@*****.**") ) self.db = mysql.connector.Connect(**login_info) self.cursor = self.db.cursor() self.tmp_musician_t=randstring() # Probably don't need this because unlikely to drop a tmp table self.cursor.execute("""DROP TABLE IF EXISTS %s""" % self.tmp_musician_t) # Create tmp animal table self.cursor.execute(""" CREATE TABLE %s ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name varchar(50), instrument varchar(25), email VARCHAR(50)) """ % self.tmp_musician_t) # Then populate for musician in self.musician_tuple: lrecord=("INSERT INTO %s " % self.tmp_musician_t) + \ ("(name, instrument, email) VALUES ('%s', '%s', '%s')" % musician) self.cursor.execute(lrecord) self.db.commit()
def login_encrypted_challenge_view(request): challenge = randstring(40) encrypted_challenge = request.session['public_key'].sign_and_encrypt(challenge) request.session['plaintext_challenge'] = challenge request.session['encrypted_challenge'] = encrypted_challenge return render_to_response("login_encrypt.html", {'encrypted_challenge': encrypted_challenge}, context_instance=RequestContext(request))
def setUp(self): self.musician_tuple = (("Chris Squire", "bass", "*****@*****.**"), ("Bill Bruford", "drums", "*****@*****.**"), ("Steve Howe", "guitar", "*****@*****.**"), ("Geddy Lee", "bass", "*****@*****.**"), ("Neil Peart", "drums", "*****@*****.**"), ("Alex Lifeson", "guitar", "*****@*****.**")) self.db = mysql.connector.Connect(**login_info) self.cursor = self.db.cursor() self.tmp_musician_t = randstring() # Probably don't need this because unlikely to drop a tmp table self.cursor.execute("""DROP TABLE IF EXISTS %s""" % self.tmp_musician_t) # Create tmp animal table self.cursor.execute(""" CREATE TABLE %s ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name varchar(50), instrument varchar(25), email VARCHAR(50)) """ % self.tmp_musician_t) # Then populate for musician in self.musician_tuple: lrecord=("INSERT INTO %s " % self.tmp_musician_t) + \ ("(name, instrument, email) VALUES ('%s', '%s', '%s')" % musician) self.cursor.execute(lrecord) self.db.commit()
def generate(user): """ Given a User object, create a new OneTimePassword object and save it to the database. Return the newly created OneTimePassword object with the raw_password attribute set. """ otp = OneTimePassword(user=user) otp.algorithm = "sha512" otp.iterations = 1000 otp.raw_password = randstring(40) otp.salt = randstring(16) otp.expiration_counter = 0 otp.hash = OneTimePassword._make_hash(otp.algorithm, otp.iterations, otp.raw_password, otp.salt) otp.save() return otp
def login_sign_view(request): challenge = randstring(40) request.session['signature_challenge'] = challenge return render_to_response("login_sign.html", {'signature_challenge': challenge}, context_instance=RequestContext(request))