views:

67

answers:

1

I have a C# winforms app with a form for user preferences. An admin account should be able to show a dropdown of user names stored in a security table which will allow the admin to change that user's preferences. All is well and good on that front, except for the fact that both usernames and passwords are stored encrypted in the database. I have functions for encryption/decryption, but as it stands now the combobox is databound to the username field of the users table. Is there a way to cause the data to be filtered through my decryption function before being bound to the combobox?

This is not such a big deal right now, and could be easily replaced with a different method than binding directly, but in the future I will need to do many more fields in the same way, so I would like to find a way to databind and use encrypted data.

Thanks for your help in advance!

+2  A: 

You could write an ITypedList that wraps your datasource and returns custom PropertyDescriptors that decrypt the data in GetValue and encrypt it in SetValue.

SLaks
Had a similar solution in a project recently using Linq to Sql with a custom property in the entity partial class. Although it could be a little slow when working with large datasets, I was happy with the overall performance.
AJ