我正在尝试在 Linux 中制作一个 bash 脚本,其中嵌入了一些加密数据,然后使用 openssl 检索和解密,如下所示:
cat | openssl des3 -d -a -salt -pass pass:asdf > output.txt <<EOF
U2FsdGVkX1/zN55FdyL5j1nbDVt5vK4V3WLQrnHPoycCJPwWO0ei3PCrrMqPaxUH.....blablablah data
EOF
唯一的问题是,当脚本到达时我必须按 Enter 键这个位置。 我尝试过改变 \n 的放置方式,但没有成功。
我无法像这样手动输入所有要嵌入的文件!
感谢您的帮助!
I'm trying to make a bash script in linux where some encrypted data is embedded and then retrieved and decrypted with openssl, like this:
cat | openssl des3 -d -a -salt -pass pass:asdf > output.txt <<EOF
U2FsdGVkX1/zN55FdyL5j1nbDVt5vK4V3WLQrnHPoycCJPwWO0ei3PCrrMqPaxUH.....blablablah data
EOF
The only problem with this, that would otherwise work, is that I have to hit enter when the script reaches this position. I have tried changing the way \n are placed, but no luck.
I can't afford to press manually enter for all the files that are going to be embedded like this one!!
Thanks for your help!
发布评论
评论(1)
这里有一些错误:
你不应该同时使用
cat | ...
以及此处文档 (<)。 使用其中之一。
您的示例不可测试,因为示例文本不是任何输入的 DES3 加密。
您的示例不可测试,
此示例按预期工作:
也就是说,它将 Base64 编码的加密版本的
~/.profile
写入文件 /tmp/output.txt。这是一个带有此处文档的有效解密示例:
在您自己的家中安全舒适地尝试此操作...
A couple of things wrong here:
You shouldn't use both
cat | ...
and also a here document (<<EOF
). Use one or the other.Your example isn't testable because the example text is not the DES3 encryption of any input.
This example works as expected:
That is, it writes an encrypted version of
~/.profile
, base64 encoded, to file /tmp/output.txt.Here's a working decryption example with a here document:
Try this in the safety and comfort of your own home...