Skip to content

Commit 662849a

Browse files
committed
Fix SwiftLint warning
1 parent a2d5ee1 commit 662849a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/CryptomatorCryptoLib/Cryptor.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ public class Cryptor {
155155

156156
// decrypt:
157157
let cleartext = try AesSiv.decrypt(aesKey: masterkey.aesMasterKey, macKey: masterkey.macMasterKey, ciphertext: [UInt8](ciphertextData), ad: [UInt8](dirId))
158-
return String(decoding: Data(cleartext), as: UTF8.self)
158+
guard let cleartextString = String(bytes: cleartext, encoding: .utf8) else {
159+
throw CryptoError.invalidParameter("Can't UTF-8-decode cleartext")
160+
}
161+
return cleartextString
159162
}
160163

161164
// MARK: - File Header Encryption and Decryption

0 commit comments

Comments
 (0)