I have a file selector in my cocoa application, but when you hit the “Select” button I don’t believe it actually stores, or uses that file. I need to use that file later to encrypt it. The user selects a file, enters a password in an NSSecureTextfield. Though this is impossible if I have no file to work with, how can I ACTUALLY select/use a file? I need to encrypt (256 bit AES) with the contents of that file. Once I actually store it, how would I access the data to encrypt it. It wouldn’t necessarily be a text file, but maybe a sound file perhaps.
Thanks so much for your help
If I understand you correctly, you’ll first have to use a class like NDAlias (https://github.com/nathanday/ndalias) to create a “dynamic” link to your file. This is a link that will be maintained even if the file is in the meantime renamed or moved (on the same volume). It’s very easy to use:
Note: If you want to just read the contents from the file right away, without doing anything in the meantime, there is of course no need for NDAlias at all.
To read data from the file, you just do:
To do AES-256 encryption, the SSCrypto framework (http://septicus.com/products/opensource/) is your best friend. It’s also very easy to use:
And to decrypt this data you do this: