def test_encrypt_password_no_salt1(self): salt, enc1_test = crypto.encrypt_password(self.pw1) assert crypto.encrypt_password(self.pw1, salt) == (salt, enc1_test) self.sha.update(salt + self.pw1) enc1 = self.sha.hexdigest() assert enc1_test == enc1
def test_encrypt_password_with_salt(self): self.sha.update(self.salt + self.pw1) enc1 = self.sha.hexdigest() assert crypto.encrypt_password(self.pw2, self.salt)[1] != enc1 assert (crypto.encrypt_password(self.pw1, self.salt) == (self.salt, enc1))
def check_password(self, pw): """Check if the researcher's password is the one given.""" pwhash = encrypt_password(pw, str(self.pwsalt))[1] return pwhash == str(self.pwhash)
def set_password(self, pw): """Set the researcher's password.""" pwsalt, pwhash = encrypt_password(pw) self.pwsalt = pwsalt self.pwhash = pwhash
def test_encrypt_password_no_salt2(self): salt, enc1_test = crypto.encrypt_password(self.pw1) self.sha.update(salt + self.pw2) enc2 = self.sha.hexdigest() assert enc1_test != enc2