[PR #341] [CLOSED] 支持输入 Hex 格式的 AES Key 和 IV (不再强制 UTF-8) #338

Closed
opened 2026-03-03 11:42:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Finb/Bark/pull/341
Author: @kio235
Created: 2/13/2026
Status: Closed

Base: masterHead: fix/support-hex


📝 Commits (1)

  • f1fc1f8 feat: Support Hex-encoded Key and IV strings & update generation script

📊 Changes

4 files changed (+80 additions, -21 deletions)

View changed files

📝 Controller/CryptoSettingViewModel.swift (+3 -3)
📝 Model/Algorithm.swift (+40 -7)
📝 docs/en-us/encryption.md (+19 -5)
📝 docs/encryption.md (+18 -6)

📄 Description

之前的逻辑强制把 Key 和 IV 当成普通字符串 (UTF-8) 处理, 导致不兼容 OpenSSL 生成标准的随机密钥

给 Key 和 IV 添加智能判断:
如果长度等于标准长度(比如 16),照旧按普通字符串处理 -> 兼容老版本。
如果长度是标准的 2 倍(比如 32)且是有效的 Hex,自动转成二进制数据处理 -> 支持 Hex 输入。
现在 AES 初始化使用 [UInt8] 字节数组。

同时对文档进行了更新

我不太懂ios开发, 最近在使用的时候, 尝试使用openssl rand -hex 16作为 iv, 遇到了这个问题,
尝试修改了一下, 希望能有帮助


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Finb/Bark/pull/341 **Author:** [@kio235](https://github.com/kio235) **Created:** 2/13/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/support-hex` --- ### 📝 Commits (1) - [`f1fc1f8`](https://github.com/Finb/Bark/commit/f1fc1f821b1f7df17e0ac4e2526cde2c66a4c262) feat: Support Hex-encoded Key and IV strings & update generation script ### 📊 Changes **4 files changed** (+80 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `Controller/CryptoSettingViewModel.swift` (+3 -3) 📝 `Model/Algorithm.swift` (+40 -7) 📝 `docs/en-us/encryption.md` (+19 -5) 📝 `docs/encryption.md` (+18 -6) </details> ### 📄 Description 之前的逻辑强制把 Key 和 IV 当成普通字符串 (UTF-8) 处理, 导致不兼容 OpenSSL 生成标准的随机密钥 给 Key 和 IV 添加智能判断: 如果长度等于标准长度(比如 16),照旧按普通字符串处理 -> 兼容老版本。 如果长度是标准的 2 倍(比如 32)且是有效的 Hex,自动转成二进制数据处理 -> 支持 Hex 输入。 现在 AES 初始化使用 [UInt8] 字节数组。 同时对文档进行了更新 我不太懂ios开发, 最近在使用的时候, 尝试使用`openssl rand -hex 16`作为 iv, 遇到了这个问题, 尝试修改了一下, 希望能有帮助 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 11:42:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Bark#338
No description provided.