@@ -131,28 +131,28 @@ public class FileHashImpl: NSObject {
131131 private func decodeKey( _ key: String , encoding: String ? ) -> Data ? {
132132 let enc = ( encoding ?? " utf8 " ) . lowercased ( )
133133 switch enc {
134- case " utf8 " :
135- return key. data ( using: . utf8)
136- case " hex " :
137- let cleaned = key. replacingOccurrences ( of: " " , with: " " )
138- guard cleaned. count % 2 == 0 else { return nil }
139- var data = Data ( capacity: cleaned. count / 2 )
140- var idx = cleaned. startIndex
141- while idx < cleaned. endIndex {
142- let nextIdx = cleaned. index ( idx, offsetBy: 2 )
143- let byteString = cleaned [ idx..< nextIdx]
144- if let num = UInt8 ( byteString, radix: 16 ) {
145- data. append ( num)
146- } else {
147- return nil
134+ case " utf8 " :
135+ return key. data ( using: . utf8)
136+ case " hex " :
137+ let cleaned = key. replacingOccurrences ( of: " " , with: " " )
138+ guard cleaned. count % 2 == 0 else { return nil }
139+ var data = Data ( capacity: cleaned. count / 2 )
140+ var idx = cleaned. startIndex
141+ while idx < cleaned. endIndex {
142+ let nextIdx = cleaned. index ( idx, offsetBy: 2 )
143+ let byteString = cleaned [ idx..< nextIdx]
144+ if let num = UInt8 ( byteString, radix: 16 ) {
145+ data. append ( num)
146+ } else {
147+ return nil
148+ }
149+ idx = nextIdx
148150 }
149- idx = nextIdx
150- }
151- return data
152- case " base64 " :
153- return Data ( base64Encoded: key)
154- default :
155- return nil
151+ return data
152+ case " base64 " :
153+ return Data ( base64Encoded: key)
154+ default :
155+ return nil
156156 }
157157 }
158158
0 commit comments