Manually decrypting something which has been encrypted using Rails ActiveSupport::MessageEncryptor

Hello all,

I am trying to decrypt a string which has been encrypted in my rails project. This is how I am encrypting the data:

def encrypt_text(text_To_encrypt)

        # Ref:
        secret = Rails.configuration.miscconfig['encryption_key']
        salt = Rails.configuration.miscconfig['encryption_salt']
        key =, 32)
        crypt =
        encrypted_data = crypt.encrypt_and_sign(text_To_encrypt)


I am able to decrypt using decrypt_and_verify, but I want to decrypt it manually using openssl. How do I do that. I tried doing the following command:

echo “<encrypted_message>”|openssl enc -d -aes-256-cbc -a -salt

This encrypted message is the first part of the “encrypted_data” from the above code. This doesn’t include the IV. It didn’t work, so I tried giving the entire encrypted_data, which didn’t work as well. After giving the password, it shows “bad magic number”. I don’t understand what I am doing wrong. Can someone please give me a push in the right direction.