Re: Community Suggestions on Encryption
Re: Community Suggestions on Encryption
- Subject: Re: Community Suggestions on Encryption
- From: Brad Stone <email@hidden>
- Date: Thu, 17 Feb 2011 09:37:05 -0500
FYI - for anyone trying to solve this problem use this NSData category which puts a user friendly wrapper around CCCryptor. It works perfectly! See this (scroll to the bottom) http://stackoverflow.com/questions/2579453/nsdata-aes-class-encryption-decryption-in-cocoa and here for the source code: https://github.com/nicerobot/objc/tree/master/NSData/NSData+AES/
Cheers to the author for sharing.
On Feb 16, 2011, at 10:48 AM, Brad Stone wrote:
> Jean - thanks to your tip I was able to find this code at http://pastie.org/966473. It works very well (I tried to paste it below but it was too big) for NSString ivars.
>
> What I'm working on now is to try to figure out how to encrypt/decrypt an NSData iVar.
>
> I have an NSData ivar which is binded to an NSTextView. The text view is rich text, the user can drag in jpgs, changes fonts, styles, etc.. If I send it to this code, encrypt it and decrypt it, I get back chinese characters. I don't think the approach is to store the text separately from the rest of the rich text data so I'm investigating how I can write similar code for NSData.
>
> On Feb 15, 2011, at 10:52 AM, Jean-Daniel Dupas wrote:
>
>>
>> Le 15 févr. 2011 à 16:35, Brad Stone a écrit :
>>
>>> I've been doing a lot of hunting to find a simple way for me to encrypt an NSString and NSData. I've found a bunch of useful blogs like Cocoa Nut (http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa (http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the SSCrypto site (http://septicus.com/products/opensource/). The thing is however that these, among others I've found (like "cocoa-ae"s from 2009), are dated. The SSCrypto files haven't been updated since 2006 and these blogs are of similar age.
>>>
>>> My question is simple: can I get this done without having to dive deep into the world of OpenSSL? If so, how?
>>>
>>> I have about four NSString iVars and one NSData iVar I want to encrypt. I wrote my own test code to encrypt/decrypt an NSString on the fly and have it work with core data transparently to the user. I'm at the point now where I need to replace that test code with something real. From all I've read, OpenSSL is the way to go but I've also read it's very difficult to implement. I know nothing about it. What initially attracted me to SSCrypto is that it's simple (i.e. NSData *decryptedText = [crypto decrypt:@"aes256"]) but I'm worried about using something relatively old and using a third party framework.
>>>
>>
>> For AES (and SHA, and HMAC), use CommonCrypto API which is part of libSystem.
>>
>> man CCCryptor for details. (or search in Xcode doc).
>>
>> -- Jean-Daniel
>>
>>
>>
>>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden