Standard format to encode AES cipher and random IV As far as I understood, a secret key (same length as CBC block size) and an initialization vector (IV) are needed to decrypt a AES-256-CBC encrypted string. As the IV should better be random, it has be distributed in plaintext along with the encrypted text.

Is there a standard or at least "commonly used" format to format the result?

E.g. /usr/bin/openssl seems to concatenate "Salted___" + IV + cyphertext and then base64 encode everything. Would this be a recommended way? I want to store the encrypted text and still be able to decrypt it in 10 years with any PHP/Python/Java library.
Is there a standard or at least "commonly used" format to format the result?


PKCS #7 (and CMS which is a further development) describes a standard format for encrypted data. While it's mainly meant for public key encrypted data, it also has options for symmetric keys. It's rather complex due to all the features it supports, however, so unless you can find a library that does all the encoding and parsing for you, you may want to do something simpler if you only need the format for your own use.

Another "format" that's probably quite commonly used is simply to concatenate the IV and the encrypted message (and then MAC, if applicable). However, that's not very discoverable.


  E.g. /usr/bin/openssl seems to concatenate "Salted___" + IV + cyphertext and then base64 encode everything. Would this be a recommended way?


Actually, "Salted___" in OpenSSL indicates password-based encryption, and the value that follows is not an IV for the cipher, but a salt for deriving the key and IV from a password. If you are using a key directly, rather than a password, you shouldn't reuse that format, or it'll just cause confusion.


  I want to store the encrypted text and still be able to decrypt it in 10 years with any PHP/Python/Java library.


Other than PKCS #7 or CMS, I would suggest using just plain ASCII to describe the format, cipher and mode and then concatenating the binary IV + data. It will expand the data, but space if usually cheap, and ASCII will always be readable.