I have a Tabular User Maintenace Window that uses Datawindow Select / Update.
I need to encrypt the password saved on the MSSQL Database.
I have a function f_decrypt for Powerbuilder and for dbo.
How can I use dw.Update() to encrypt the password?
A small book could probably be written on the possibilities. My first question is the requirement to store encrypted passwords, or does the password have to go over the wire encrypted. If storage is the only requirement, I'd tend to let the DBMS do what a team of high level programmers spent months trying to get right, rather than to try to reinvent the wheel myself. Even if it has to go over the wire encrypted, I'd look at DBMS-provided options first.
If you have to do it client-side and deal with hashing, salting, preventing reverse engineering of your code, et al, yourself, there are still probably a dozen ways to do it. The first way I'd try is to make a DataWindow with a dummy column for the password user interface, as well as the column in the table, e.g.
SELECT ' ' as password_ui,
table.password_storage,
...
FROM table
....
I'd put password_ui on the DataWindow's user interface, and leave password_storage off the user interface, but make sure password_storage is included in the Update Properties as an updatable column. Then, on ItemChanged, if the column changed is password_ui, I'd
CHOOSE CASE dwo.Name
CASE "password_ui"
SetItem (row, "password_storage", f_encrypt (data))
END CHOOSE
Good luck,
Terry.