Re: Encrypting core data properties
Re: Encrypting core data properties
- Subject: Re: Encrypting core data properties
- From: Lee Morgan <email@hidden>
- Date: Sun, 19 Jun 2005 05:11:11 -0400
On Jun 19, 2005, at 3:09 AM, J. Atwood wrote: I'm trying to come up with a scheme to encrypt sensitive properties for one of my entities. I found a nice package for carrying out the actual encryption (SSCrypto.framework), but I'm unsure as to when I should perform the encryption/decryption, as I'm using core data w/ cocoa bindings.
For instance, one of the properties of a customer entity might be credit card number. I want the user to be able to enter the credit card number into a text field normally, but I want core data to run the string through my encryption method before storing it in the application's data file. Similarly, I want the encrypted string to be decrypted before it is shown in its text box (when the appropriate instance of its customer is selected).
(In the future, I might build a condition into the encrypt/decrypt methods that prompts for a password.)
How should I do this? I tried using a custom transformer, but I'm having trouble getting in to work correctly. Is there a better way? How do other people protect sensitive data within their applications?
CoreData gives you alot of opportunities to perform your transformation on the data. For example if you only care about the data being encrypted when it's stored to disk then you can override NSMangedObject's initWithEntity:insertIntoManagedObjectContext: and willSave methods.
If you need it to be secure even while it's in memory you can probably override setValue:forKey: and valueForKey: in which case you probably have to override setPrimitiveValue:forKey: and permitiveValueForKey: also.
I haven't created a value transformer before so I don't know when the values get transformed, I assume it's just before it gets to the GUI which would keep your content secure all the time excluding what is displayed on the screen - thats just a guess though.
- Lee |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden