Page 1 of 1

Decrypt SQl Logins

PostPosted: Thu Mar 17, 2022 12:03 pm
by SBarnes
How can I decrypt the value of SQLLogin and ReportSQLLogin from HR_Staff so that I can execute usp_Jiwa_Grant_Application_Permissions and usp_Jiwa_Grant_Reporting_Permissions from code?

Re: Decrypt SQl Logins  Topic is solved

PostPosted: Thu Mar 17, 2022 12:20 pm
by Mike.Sheen
SBarnes wrote:How can I decrypt the value of SQLLogin and ReportSQLLogin from HR_Staff so that I can execute usp_Jiwa_Grant_Application_Permissions and usp_Jiwa_Grant_Reporting_Permissions from code?


You'll need to also get from the HR_Staff record the SQLLoginLastSavedDateTime and ReportsLoginLastSavedDateTime - this is used as salt for the decryption - and that's done by the DecryptString method of the JiwaEncryption.JiwaEncrypt class.

So, new up and instance of the JiwaEncryption.JiwaEncrypt class (no factory here):
Code: Select all
encryption = new JiwaEncryption.JiwaEncrypt();


Then call the DecryptString method, passing the encrypted text and the salt formatted by JiwaODBC.database.FormatDateTime:

Code: Select all
loginPlainText = Encryption.DecryptString(EncryptedSQLLogin, Manager.Database.FormatDateTime(SQLLoginLastSavedDateTime, true));