
- 注释掉Podfile中的Alamofire依赖,更新Podfile.lock以反映更改。 - 在yana/APIs/API-README.md中新增自动认证Header机制的详细文档,描述其工作原理、实现细节及最佳实践。 - 在yana/yanaApp.swift中将print语句替换为debugInfo以增强调试信息的输出。 - 在API相关文件中实现用户认证状态检查和相关header的自动添加逻辑,提升API请求的安全性和用户体验。 - 更新多个文件中的日志输出,确保在DEBUG模式下提供详细的调试信息。
51 lines
1.6 KiB
Swift
51 lines
1.6 KiB
Swift
import Foundation
|
|
|
|
/// OC版本DES加密测试
|
|
struct DESEncryptOCTest {
|
|
|
|
/// 测试 OC 版本的 DES 加密功能
|
|
static func testOCDESEncryption() {
|
|
debugInfo("🧪 开始测试 OC 版本的 DES 加密...")
|
|
debugInfo(String(repeating: "=", count: 50))
|
|
|
|
let key = "1ea53d260ecf11e7b56e00163e046a26"
|
|
let testCases = [
|
|
"test123",
|
|
"hello world",
|
|
"password123",
|
|
"sample_data",
|
|
"encrypt_test"
|
|
]
|
|
|
|
for testCase in testCases {
|
|
if let encrypted = DESEncrypt.encryptUseDES(testCase, key: key) {
|
|
debugInfo("✅ 加密成功:")
|
|
debugInfo(" 原文: \"\(testCase)\"")
|
|
debugInfo(" 密文: \(encrypted)")
|
|
|
|
// 测试解密
|
|
if let decrypted = DESEncrypt.decryptUseDES(encrypted, key: key) {
|
|
let isMatch = decrypted == testCase
|
|
debugInfo(" 解密: \"\(decrypted)\" \(isMatch ? "✅" : "❌")")
|
|
} else {
|
|
debugError(" 解密: 失败 ❌")
|
|
}
|
|
} else {
|
|
debugError("❌ 加密失败: \"\(testCase)\"")
|
|
}
|
|
debugInfo("")
|
|
}
|
|
|
|
debugInfo(String(repeating: "=", count: 50))
|
|
debugInfo("🏁 OC版本DES加密测试完成")
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
extension DESEncryptOCTest {
|
|
/// 在 AppDelegate 中调用此方法进行测试
|
|
static func runInAppDelegate() {
|
|
DESEncryptOCTest.testOCDESEncryption()
|
|
}
|
|
}
|
|
#endif |