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