Skip to content

Commit 116d8cf

Browse files
committed
GCM 还没准备好示例代码,暂时禁用
1 parent ab61dda commit 116d8cf

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Controller/CryptoSettingViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class CryptoSettingViewModel: ViewModel, ViewModelType {
135135
return Output(
136136
initial: Driver.just((
137137
algorithmList: [Algorithm.aes128, Algorithm.aes192, Algorithm.aes256],
138-
modeList: ["CBC", "ECB", "GCM"],
138+
modeList: ["CBC", "ECB", /* "GCM" */], // GCM 还没准备好示例代码,暂时禁用
139139
paddingList: ["pkcs7"],
140140
initialFields: dependencies.settingFieldRelay.value
141141
)),

Model/Algorithm.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,10 @@ struct AESCryptoModel {
6767

6868
var iv = ""
6969
if ["CBC", "GCM"].contains(cryptoFields.mode) {
70-
var expectIVLength = 0
71-
if cryptoFields.mode == "CBC" {
72-
expectIVLength = 16
73-
}
74-
else if cryptoFields.mode == "GCM" {
75-
expectIVLength = 12
76-
}
70+
let expectIVLength = [
71+
"CBC": 16,
72+
"GCM": 12
73+
][cryptoFields.mode] ?? 0
7774

7875
if let ivField = cryptoFields.iv, ivField.count == expectIVLength {
7976
iv = ivField

0 commit comments

Comments
 (0)