Encrypt / Decrypt Passwords in the Database  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Encrypt / Decrypt Passwords in the Database

Postby SBarnes » Mon Jul 09, 2018 11:10 am

Hi Mike,

Is there a stored procedure in the database that will either encrypt or decrypt a HR_Staff password?

To explain the problem we are working on upgrading the web site of a customer who uses an old version of Jiwa that allows staff members to login using their Jiwa credentials and all the stored procedures of course assume that the password field in HR_Staff is clear text.

I can add a custom field to HR_Staff to get around it but would prefer not to for several obvious reasons i.e. two passwords would be confusing and storing the password as plain text isn't what I want to do.

Given this is using and extending the web API, if there is a simple way to encrypt the plain string and then call the ORMLite stored proc function with that it would work as an alternative I just need to know how to do it?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Encrypt / Decrypt Passwords in the Database  Topic is solved

Postby SBarnes » Mon Jul 09, 2018 2:16 pm

Ok so after some hunting around this is how to do it

Code: Select all
            JiwaFinancials.Jiwa.JiwaServiceModel.Tables.HR_Staff hrstaff = Db.Select<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.HR_Staff>().Where(s=> s.SName == request.LogonCode ).FirstOrDefault();
            if (hrstaff == null)
            {
               return result;
            }
            JiwaFinancials.Jiwa.JiwaEncryption.JiwaEncrypt jiwaEncrypt = new JiwaFinancials.Jiwa.JiwaEncryption.JiwaEncrypt();
            DateTime PDate = hrstaff.PasswordLastChangedDateTime == null ? DateTime.Now : (DateTime) hrstaff.PasswordLastChangedDateTime;
            string pwdenc = jiwaEncrypt.EncryptString(request.LogonPassword, manager.Database.FormatDateTime(PDate, true));
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 18 guests

cron