I want to save the password for configuration setting (e.g. new SMTP profile). If I write insert plain text for password column in SMTPSETTINGS
table of internal database I get no error but going back to Email Settings option on gateway webpage shows Internal Error.
Skipping password column in insert query does create a new SMTP profile. So I think I need to encrypt the plain text before inserting the value.
I tried SHA1 algorithm to encrypt the password (‘password’) and inserted in internal DB table. It gets inserted as below but I get Internal Error
import base64
import hashlib
hash = base64.b64encode(hashlib.sha1('password').digest())
query = '''INSERT INTO SMTPSETTINGS (SMTPSETTINGS_ID, NAME, DESCRIPTION, HOSTNAME, PORT, USESSLPORT, SSLENABLED, USERNAME, PASSWORD, SMTPTIMEOUT, DEBUGMODEENABLED, SSLPROTOCOLS)
VALUES(3, 'SMTP6', '', '192.168.1.3', 25, True, True, 'user', ?, 10000, FALSE, 'TLSv1.2')'''
system.db.runPrepUpdate(query, [hash], 'InternalDB')
In above table both SMTP5 and SMTP6 have same password ‘password’, so SHA1 is not the correct encryption. MD5 encryption returns ‘X03MO1qnZdYdgyfeuILPmQ==’ for ‘password’ and give the same Internal Error on adding to database.
Is there any way to find which encryption algorithm is used?