-
Notifications
You must be signed in to change notification settings - Fork 2
auth
It contains all the authentication related functions/classes.
This function verifies the availability of the sudo token. If present, it takes no action; otherwise, it displays a GUI dialog box to enter the sudo password (maximum tries: 3).
from csilibs.auth import checkpass
checkpass()
This function takes a file path as input and simply computes the MD5 hash of it.
Takes a password as an argument and returns the key derived from that password for the Fernet() function to use. This key is utilized by the encrypt
& decrypt
functions below.
Takes the return value of gen_key()
, the plain file path, and the resulting encrypted file path as arguments. It also deletes the plain file after encrypting it, so use it carefully.
Takes the return value of gen_key()
, the encrypted file path, and the resulting decrypted file path as arguments.
from csilibs.auth import gen_key, encrypt, decrypt
derived_key = gen_key('password123!')
# Deletes the secret.txt file after encryption
encrypt(derived_key,'/opt/CSI-Libs/secret.txt','/opt/CSI-Libs/secret.enc')
# Does not delete the secret.enc file after decryption
decrypt(derived_key,'/opt/CSI-Libs/secret.enc','/opt/CSI-Libs/secret.txt')
Contact @PakCyberbot in case of any confusion!