Jul-27-2023, 12:40 AM
Greetings to you all!
I'm trying to pull out some data from MS SQL DB.
I have to encrypt the user name and the pass, I found how to encrypt a text file and how to access my MS SQL DB but I have no idea how to put these two scripts together
.
Here is the encryption snippet:
Thank you
I'm trying to pull out some data from MS SQL DB.
I have to encrypt the user name and the pass, I found how to encrypt a text file and how to access my MS SQL DB but I have no idea how to put these two scripts together

Here is the encryption snippet:
# Making the encryption key: from cryptography.fernet import Fernet key = Fernet.generate_key() print(key) # # Incrypting the Password file from cryptography.fernet import Fernet key = b'5YBR7_2gufXlbmMg13QB9c71WR6h9m2Sq49tLwCsOVk=' cipher_suite = Fernet(key) ciphered_text = cipher_suite.encrypt(b'Mypassword') with open('C:/01/Python _passwords/encripted_bytes.bin', 'wb') as file_object: file_object.write(ciphered_text)And the DB access snipped:
import pyodbc conn = pyodbc.connect('DRIVER={SQL Server};SERVER=myremoteServer5.hps.com,1333;DATABASE=MYMSSQLDB;UID=aa;PWD=allgetlost') cursor = conn.cursor() for row in cursor.tables(): print(row.table_name)Any help is really appreciated.
Thank you