Reputation: 3155
How can I trick the -in
argument of the OpenSSL command line tool in order to get data from string instead a file?
Normally, I could use echo
command to do it:
echo 'test string 1' | openssl enc -aes-256-cbc -a -salt -pass pass:mypassword
Is there a way I can do it without echo
and pipe? Similar to the -pass pass:
argument?
Thanks in advance!
Upvotes: 6
Views: 9525
Reputation: 3155
I found a way to go around this! Instead of passing everything before and since openssl has an interactive mode, it's possible to run the command without input:
openssl enc -aes-256-cbc -a -salt -pass pass:mypassword
And OpenSSL will be waiting for data to encrypt. This can be also useful for streams!
Then type in the string or data you want to encrypt and send a EOT
(End of Transmission) in Terminal is usual ^D
Control+D
it it will output to stdout
the encrypted string!
Hope this may help someone some day!
Upvotes: 3
Reputation: 71595
If your shell is bash and your OS supports it, you can use process substitution:
openssl enc -in <(echo 'test string 1') -aes-256-cbc -a -salt -pass pass:mypassword
Upvotes: 6