SomethingIsCrazy
SomethingIsCrazy

Reputation: 23

En-Decrypt NSData with RNCryptManager over CoreData

I have never anything to do with data encryption, So i started to work with this code

I had done anything, and it works all right if I encrypt some NSData and directly Decrypt the NSData. But it is very hard to understand how this code work. It would be nice anyone can help me.

I would store some Encrypted NSData in the CoreData and load it from the CoreData to DeCrypt it, but if I do this I got this output:

2013-03-19 15:31:07.197 En-Decrypt+CoreData[2603:c07] Assertion failure in +[RNCryptManager AESKeyForPassword:salt:], /Users/main/Desktop/En-Decrypt+CoreData/En-Decrypt+CoreData/RNCryptManager.m:110 2013-03-19 15:31:07.198 En-Decrypt+CoreData[2603:c07] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to create AES key for password: -1'

I have uploaded the sample xcode project here

Thanks for your help

Upvotes: 1

Views: 3098

Answers (1)

Sergey Kuryanov
Sergey Kuryanov

Reputation: 6114

Among with data you need to save salt and iv values. This is required for decryption. So modify your data model:
enter image description here

And save salt and iv with encrypted data.

Upvotes: 1

Related Questions