I am encrypting a json string in openssl. When it prints out I get mutli line out put, I need it in a single line, for storage and usability in CLI.
Run command: echo '{"foo":"this is fun","bar":"this is also fun","numbers":123456}' | openssl enc -aes-256-cbc -a
Pass: pass
Get:
U2FsdGVkX1+u90MyWMyFtrrlzFSLcuNk00Ax5XLJhzSMpuUNxwdZQgdkxSmT3KEP
LMGz5I2imE9RP0BvMAPnUq0we98bprtxAnZMHLSntfl2tRSqoyMDvW6P3+Vkr2jZ
To decrypt I run: echo "U2FsdGVkX1+u90MyWMyFtrrlzFSLcuNk00Ax5XLJhzSMpuUNxwdZQgdkxSmT3KEP
LMGz5I2imE9RP0BvMAPnUq0we98bprtxAnZMHLSntfl2tRSqoyMDvW6P3+Vkr2jZ" | openssl enc -aes-256-cbc -d -a
But this command will not work with the multi lines, if I out put to a file and the cat the file in, it works, but I need to store is as a string, in a database, with out the multi lines and to be able to run the decrypt command in CLI.
Does anyone know how this can be done or some open way to encrypt in CLI with aes and to be able to get a single line output?