Beispiel #1
0
 def matchPassword(self, pwd):
     userData = utils.openData("User")
     if self.username in userData:
         try:
             keyword = utils.decrypt(userData[self.username], pwd, True)
             if pwd == keyword:
                 self.setPassword(keyword)
                 userData.close()
                 return True
         except:
             msg = 'Username and password doesn\'t match'
     userData.close()
     return False
Beispiel #2
0
    def changePassword(self, newPassword):
        userData = utils.openData("User")

        #change all accounts in the shelf file
        accountData = utils.openData(self.username)
        for key in accountData:
            pwd = utils.decrypt(accountData[key], self.getPassword())
            accountData[key] = utils.encrypt(pwd, newPassword)
        accountData.close()

        userData[self.username] = utils.encrypt(newPassword, newPassword, True)
        self.setPassword(newPassword)
        userData.close()
Beispiel #3
0
def login():
    username = request.form.get('username', None)
    password = utils.decrypt(request.form.get('password', None))
    users = app.mongo.db.users
    user = users.find_one({'username': username})

    if user is None:
        return {'message': '用户未注册'}, utils.http_code['Not Acceptable']

    if not check_password_hash(user['password'], password):
        return {'message': '密码错误'}, utils.http_code['Forbidden']

    user_id = user['userId']
    token = utils.create_token(user_id)
    return {'message': '登录成功', 'data': {'token': token}}
 def test_decrypt_password(self):
     account_fb = self.user.getAccountList()[0]
     self.assertEqual(utils.decrypt(account_fb.getAccountPassword(), self.user.getPassword()), "pass_fb")
     account_instagram = self.user.getAccountList()[1]
     self.assertEqual(utils.decrypt(account_instagram.getAccountPassword(), self.user.getPassword()), "pass_instagram")  
 def copyPassword(self, passKey):
     copas = utils.decrypt(self.accountPassword, passKey)
     pyperclip.copy(copas)
Beispiel #6
0
 def test_encrypt_decrypt(self):
     textToEncypt = "some random text"
     encryptedText = utils.encrypt(textToEncypt, 'some_password')
     decryted_text = utils.decrypt(encryptedText, 'some_password')
     self.assertEqual(textToEncypt, decryted_text)
Beispiel #7
0
 def test_negative_decryption(self):
     textToEncypt = "some random text"
     encryptedText = utils.encrypt("Some Random Text", 'some_password')
     decryted_text = utils.decrypt(encryptedText, 'some_password')
     self.assertNotEqual(textToEncypt, decryted_text)
Beispiel #8
0
 def test_double_secure(self):
     textToEncypt = "this is a double secure test"
     encryptedText = utils.encrypt(textToEncypt, 'some_password', True)
     decryted_text = utils.decrypt(encryptedText, 'some_password', True)
     self.assertEqual(textToEncypt, decryted_text)
 def serialize(self):
     """Return object data in easily serializeable format"""
     return {'note': utils.decrypt(self.note)}