I have to encrypt an xml file using openssl command line or a C api. The output shall be Base64.
A java programm will be used for decrypting. This programm is provid
Java's SecretKeySpec uses the password ASCII bytes directly as key bytes, while OpenSSL's -pass pass:... method derives a key from the password using a key derivation function to transform the password into a key in a secure fashion.  You can either try to do the same key derivation in Java (which you probably cannot if I interpret your question correctly), or use OpenSSL's -K option to pass in a key (as hex bytes!) instead of a password.
You can find out how there.