文字:apple 密码:密码
openssl aes-256-cbc -e -a -in apple.txt
输出:U2FsdGVkX1/sqDrVkgk/7dKiCfLW+1/bgvRT/YAopJQ=
gpg -c --cipher-algo AES256 apple.txt
输出:A0ECQMCvDw3qeyQxgNg0kABv5nE4IDtSYmDTJudbl55d0GjBkiLd1B4sgbY/QQPVJX/uaHuDIb9 xhcwW/7UaxIxh9URhkHPni2IhYoOuKqm
如何同步两个结果?
答案1
该openssl
命令会对您的输入进行加盐处理并将其放入 OpenSSL 加密容器中。您可以使用该-nosalt
选项,但它会降低加密的安全性。我对该gpg
命令了解不多,但我很确定它正在执行类似操作。它的输出太大了,不可能只是加密后的单词“apple”。
答案2
即使您多次使用相同的命令,也会得到不同的输出。原因是每次都会生成一个新的 AES-256 密钥,并使用您的密码进行保护。
openssl aes-256-cbc -e -a -in password.txt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX19yNQwed5/Sq3b6/3UFGGOGVD1dSA7aCZI=
openssl aes-256-cbc -e -a -in password.txt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX19rulpZRi8u5K9iJKVN5FVFRb6ngFY1BWM=
openssl aes-256-cbc -e -a -in password.txt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX192MxevxHvc1wW0dh9P4HctQF/75HEPVB4=
openssl enc -aes-256-cbc -k test -P
salt=667E42EDE61BEA35
key=46FB1D91FC400A8E26A8B0E38CF505F026263299CF0FA541217FBC6CEED1FC0B
iv =10A3858EC9D718AB91FC45B98786FDCC
openssl enc -aes-256-cbc -k test -P
salt=34F9B481E391A831
key=CDF1D936F99147BB56B4E3441B5E1A68A15838FE43F234AA7EB9A9F903B0BD61
iv =A649443D096E6976420F4941C2608CC8
openssl enc -aes-256-cbc -k test -P
salt=51AC4B4388D5C25B
key=D70AF8238D1C597F074123C9BB23B76C9CA04AAF2C986C4A56F96CB0FF1365F9
iv =D70FB991EEE776FCD45A67830CBD3202