I need to encrypt an sensitive property of the Members in the DB... The approach I am taking is this:
public class MyEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
MemberService.Saving += MemberServiceOnSaving;
base.ApplicationStarted(umbracoApplication, applicationContext);
}
private void MemberServiceOnSaving(IMemberService sender, SaveEventArgs<IMember> saveEventArgs)
{
//Logic to Encrypt and Save Goes Here!
}
}
this is working to encrypt the value for the saving, but I dont know how to intercept the value to decrypt it when reading it... Any suggestions? Or if this is the right approach...
This approach seems fine to me - it is one that I have used.
When reading it you would simply have a utility method Decrypt in a class somewhere.
You would normally read the value when you have an instance of an IMember
var m = MemberService.GetById(100);
var decryptedVal = MyClass.Decrypt(m.Attribute);
Thanks L for replying... but I am talking about the Member Section in the CMS, see this screenshot:
I need to intercept the call the CMS does to get the member and decrypt the value... Do I need to rewrite the Member section maybe to gain control on the MemberService.GetById() Method?
Encrypt/Decrypt Member Property
I need to encrypt an sensitive property of the Members in the DB... The approach I am taking is this:
this is working to encrypt the value for the saving, but I dont know how to intercept the value to decrypt it when reading it... Any suggestions? Or if this is the right approach...
Hi,
This approach seems fine to me - it is one that I have used.
When reading it you would simply have a utility method Decrypt in a class somewhere. You would normally read the value when you have an instance of an IMember
Hope that helps!
Regards, L
Thanks L for replying... but I am talking about the Member Section in the CMS, see this screenshot:
I need to intercept the call the CMS does to get the member and decrypt the value... Do I need to rewrite the Member section maybe to gain control on the MemberService.GetById() Method?
Ah, I see - my mistake, sorry.
In that case have you thought about your own custom property editor? Then you can do the encrypting and decrypting in the getters and setter methods.
Regards L
Yes, I would also recommend custom editors and then you can use the ConvertDbToEditor and ConvertEditorToDb methods to encrypt/decrypt
Awesome L and Jeavon, will give it a try... but, seams the best solution... good idea! thanks...
is working on a reply...