Question on partially encrypting/decrypting PNG files

64 views
Skip to first unread message

helloworldpark

unread,
Aug 23, 2016, 7:40:00 AM8/23/16
to rncryptor
I am trying to encrypt/decrypt some PNG files on my iPhone app which I am currenty developing. However, it took too much time to decrypt 10 images, which costs 0.2 seconds for 10 png files(104kb on average) on iPhone 6. So I tried encrypting only the header of the PNG files, and decrypted it. Surprisingly, it took almost the same as decrypting the whole image! May I learn why this happens? Is the AES-256 a O(1) algorithm for the size of the input?

Rob Napier

unread,
Aug 23, 2016, 7:46:43 AM8/23/16
to rncr...@googlegroups.com
The vast majority of time for most small encryptions or decryptions is in the password to key translation. This is intentionally slow. Making that slow is a major security feature of RNCryptor called stretching.

If you require repeated encryption or decryption, you should use the key based API instead. This does not include the expensive password to key conversion. Exactly how to correctly use keys depends on your situation. See "Key-Based Encryption" in the docs.

Rob

Zicong Wang

unread,
Mar 6, 2017, 8:01:57 PM3/6/17
to rncryptor

Hello. 
I am new to RNcryptor swift those days. I also have a IOS project going on, and I dont know how RNcryptor works. For my understanding, I have to transform PNG file to some other format, then encrypt it, right? I may be wrong. 
Can you give me a hint, or share encryption part code to me?
Thank you very much

Rob Napier

unread,
Mar 6, 2017, 8:05:14 PM3/6/17
to rncr...@googlegroups.com
There's no need to transform the PNG data in any way. Once you have data (i.e. an NSData in ObjC or Data in Swift), that's all you need. You'll just pass that to encryptData(). See the main GitHub page. It includes samples.

-Rob

--
You received this message because you are subscribed to the Google Groups "rncryptor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rncryptor+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/rncryptor.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages