CORE

This package contains three modules:

  • DAODatabase

  • data

  • Encryption

This modules contains all the data to connect to the database and perform the necessary queries. The Encryption module implements two classes to encrypt and decrypt the password before insert them in the database with the data that provides the other two modules.

DAODatabase

This module implements an object with all the necessary functions to get the data from the database.

class CORE.DAODatabase.DAO[source]
class DAO

It is the class which implements de Data Access Object methods.

database_empty()[source]

It checks if the database is empty or not with a simple query.

Returns

It returns if the database is empty

Return type

bool

delete_many_passwords(id_list)[source]

This function is used to delete more than one password at once

Parameters

id_list (list) – Is a list with the ID’s of the passwords

delete_one_password(id)[source]

This function is used to delete the password selected by the user

Parameters

id (int) – Is the ID of the selected password

get_master_password(user)[source]

This function is used to get the decrypted password of the user with the same name as the given

Parameters

user (str) – Is the name of the user

Returns

It returns the decrypted password of the user

Return type

str

get_num_passwords(user_id)[source]

This function is used to get the number of passwords saved by the logged user

Parameters

user_id (int) – Is the ID of the logged user

Returns

It returns the number of passwords saved

Return type

int

get_user_data(user_id)[source]

This function is used to get all the data of the user logged. It returns all the data with the same ID as the given

Parameters

user_id (int) – Is the ID of the user logged

Returns

It returns a list with all the entries of the database

Return type

list

get_user_id(username)[source]

This function is used to get the ID of the user

Parameters

username (str) – Is the name of the user

Returns

It returns the ID of the user with the same username

get_user_password(id)[source]

This function is used to get the password of the selected one by the ID

Parameters

id (int) – The ID of the saved password

Returns

It returns the decrypted password

Return type

str

get_username(id)[source]

This function is used to get the username of the password saved by the logged user

Parameters

id (int) – Is the ID of the password

Returns

It returns the username of the password

Return type

str

get_users()[source]

This function is used to get all the users in the database

Returns

It returns a list with all the usernames

Return type

list[str]

new_user(username, master_password, email)[source]

This function adds a new User in the database with the params that the user enters

Parameters
  • username (str) – Is the username of the new user. It is used during the login

  • master_password (str) – Is the master password of the new user. This password is saved with an encryption. It is used during the login

  • email (str) – Is the email of the new user

reset_database()[source]

This function drops all the existing tables in the database and calls to setupDataBase()

save_user_data(id, user_id, site_name, username, password)[source]

This function is used to add a new password in the database. This password is linked with the user logged

Parameters
  • id (str) – Is the ID of the new entry

  • user_id (str) – Is the ID of the user logged

  • site_name (str) – Is the URL or the name of the website

  • username (str) – Is the username linked on the site name

  • password (str) – Is the password used in the website or app. This password is saved with an encryption

setup_database()[source]

This function executes the necessary queries to set up the database.

update_master_password(new_password, user)[source]

This function is used to update the master password of the user given

Parameters
  • new_password (str) – Is the new password of the user

  • user (str) – Is the name of the user

update_site_name(id, new_site_name)[source]

This function is used to update the site name of the password selected by it ID

Parameters
  • id (int) – Is the ID of the password

  • new_site_name (str) – Is the new site name of the password selected

update_user_password(id, new_password)[source]

This function is used to update the password of the selected one by it ID

Parameters
  • id (int) – Is the ID of the password

  • new_password (str) – Is the new password of the selected one

update_username(id, new_username)[source]

This function is used to update the username of the password selected by it ID

Parameters
  • id (int) – Is the ID of the password

  • new_username (str) – Is the new username of the password selected

data

This module implements all the necessary data for the CORE to work. It only has one class named Data.

class CORE.data.Data[source]
class Data

The Data class implements all necessary data in variables. They establish the data directories and the queries for the database

Encryption

This module uses the cryptography package for the encryption. There are two main methods encrypt() and decrypt(). These methods are the ones which encrypts and decrypts the passwords from the database.

CORE.Encryption.decrypt(password)[source]

This method is used to decrypt the password stored in the database. It calls loadKey() function to get the value of the key. Then, it generates a Fernet object which is used to decrypt the password given.

Parameters

password – It is the value of the password stored in the database

Returns

It returns the decrypted value of the password

Return type

str

CORE.Encryption.encrypt(password)[source]

This is the main method of the class. It generates a key if there is non making a call to keyGenerator(). Then, it reads the value of the key and generates a Fernet object which is used to encrypt a string with the generated key.

Parameters

password – It is the password that the user wants to be encrypted

Returns

It returns the value of the encrypted password

Return type

str

CORE.Encryption.key_check()[source]

This method checks if the generated key exists or not.

Returns

It returns True or False

Return type

bool

CORE.Encryption.key_generator()[source]

This method generates a file with the necessary key to encrypt and decrypt the passwords if there is non. The name of the file and it’s directory is designated by the data module.

CORE.Encryption.load_key()[source]

This method reads the key in the file returns its value.

Returns

It returns the value of that key

Return type

str