Databinding and encrypted password

  • Thread starter Thread starter Roland Riess
  • Start date Start date
R

Roland Riess

Hi NG,

I don't know if I'm just missing the forest through the trees, or if it
is really that complicated:

I want to save a password that is entered/changed through a text control
in a form. The control is bound to a dataset and the password shall be
stored as an encrypted text in the database.

I first tried to control the en- and decryption in the textbox's Format
and Parse handler but I ended up in sometimes having the password either
unencrypted or twice encrypted in the db.

Then I tried to use Enter and Leave handlers to de- and encrypt the
password before saving but this way, too, I can end up with unencrypted
oder twice encrypted passwords in the db.

Did somebody have this kind of problem before and knows a solution or
could point me to the right direction? I searched the archives but could
not find anything fitting my case.

Thanks in advance.
Regards
Roland
 
Roland,

Are you controlling the update and query manually? I would wrap the
call to update in a set of methods you could call which will do the
encrypting/decrypting for you when you update/query the database. This way,
you don't have to worry about the controls doing the encrypting.

Ideally, you would place this kind of functionality in the buisness
layer (or data layer, depending on your design), and it wouldn't be left to
the user to encrypt/decrypt these values.

Hopet his helps.
 
Hi Nicholas,
Roland,

Are you controlling the update and query manually?
Yes, I am.
I would wrap the
call to update in a set of methods you could call which will do the
encrypting/decrypting for you when you update/query the database. This way,
you don't have to worry about the controls doing the encrypting.
I think that is a good idea, I was too much clinging to the databinding
mechanisms of the controls - seems like if I wasn't wrong about the
forest and the trees :-)

Thanks a lot for pointing me to the right direction!

Regards
Roland
 
Back
Top