Salt is used for one-way functions, such as password hashing.
Random IV is used for two-way functions, such as data encryption, which can subsequently be decrypted.
Both of them are random bytes and are used to prevent the same information from generating the same result after applying this function. Therefore, if two people choose the same password to store their data and store the same information, the encrypted bytes will be different.
You can save them along with the encrypted file.
Also use more than 1 iteration with PBKDF2, otherwise it will be useless. According to Wikipedia, iOS 3 uses 2,000 iterations, and iOS 4 uses 10,000.
Andrew T Finnell
source share