base64命令 去掉 -w 0,macOS不支持

This commit is contained in:
Fin 2024-05-29 15:24:08 +08:00
parent 0238cacf5d
commit a49b998537
4 changed files with 6 additions and 2 deletions

View File

@ -148,6 +148,7 @@ ivComment = "IV can be randomly generated, but if it is random, it needs to be p
opensslEncodingComment = "openssl requires Hex encoding of manual keys and IVs, not ASCII encoding.";
ciphertextComment = "URL encoding the ciphertext, there may be special characters.";
consoleComment = "The console will print";
base64Notice = "If you get a 'Decryption Failed' prompt, try adding '-w 0' after the base64 command.";
keyComment = "Must be %d bit long";
removeMessage = "Remove";

View File

@ -148,6 +148,7 @@ ivComment = "IV rastgele oluşturulabilir, ancak rastgele ise iv parametresinde
opensslEncodingComment = "openssl, manuel anahtarların ve IV'lerin ASCII kodlamasını değil, Hex kodlamasını gerektirir.";
ciphertextComment = "URL şifreli metni kodlarken özel karakterler olabilir.";
consoleComment = "Konsola şunları yazdırır";
base64Notice = "If you get a 'Decryption Failed' prompt, try adding '-w 0' after the base64 command.";
keyComment = "%d bit uzunluğunda olmalıdır";
removeMessage = "Sil";

View File

@ -148,6 +148,7 @@ ivComment = "IV可以是随机生成的但如果是随机的就需要放在 i
opensslEncodingComment = "OpenSSL 要求输入的 Key 和 IV 需使用十六进制编码。";
ciphertextComment = "密文可能有特殊字符,所以记得 URL 编码一下。";
consoleComment = "控制台将打印";
base64Notice = "如果提示 Decryption Failed 尝试在 base64 命令后面 加上 -w 0";
keyComment = "必须%d位";
removeMessage = "删除";

View File

@ -121,8 +121,9 @@ class CryptoSettingViewModel: ViewModel, ViewModelType {
# \(NSLocalizedString("opensslEncodingComment"))
key=$(printf $key | xxd -ps -c 200)
iv=$(printf $iv | xxd -ps -c 200)
ciphertext=$(echo -n $json | openssl enc -aes-\(fields.algorithm.suffix(3))-\(fields.mode.lowercased()) -K $key \(iv.count > 0 ? "-iv $iv " : "")| base64 -w 0)
# \(NSLocalizedString("base64Notice"))
ciphertext=$(echo -n $json | openssl enc -aes-\(fields.algorithm.suffix(3))-\(fields.mode.lowercased()) -K $key \(iv.count > 0 ? "-iv $iv " : "")| base64)
# \(NSLocalizedString("consoleComment")) "\((try? AESCryptoModel(cryptoFields: fields).encrypt(text: "{\"body\": \"test\", \"sound\": \"birdsong\"}")) ?? "")"
echo $ciphertext