浏览代码

Optionality is removed from return type

Eugene Berdnikov 4 年之前
父节点
当前提交
b8600152d8

+ 2 - 2
Sources/CryptoSwift/Foundation/Array+Foundation.swift

@@ -16,8 +16,8 @@
 import Foundation
 
 public extension Array where Element == UInt8 {
-  func toBase64() -> String? {
-    Data( self).base64EncodedString()
+  func toBase64() -> String {
+    Data(self).base64EncodedString()
   }
 
   init(base64: String) {

+ 1 - 1
Sources/CryptoSwift/String+Extension.swift

@@ -81,7 +81,7 @@ extension String {
   /// - parameter cipher: Instance of `Cipher`
   /// - returns: base64 encoded string of encrypted bytes
   @inlinable
-  public func encryptToBase64(cipher: Cipher) throws -> String? {
+  public func encryptToBase64(cipher: Cipher) throws -> String {
     try self.bytes.encrypt(cipher: cipher).toBase64()
   }
 

+ 1 - 1
Tests/CryptoSwiftTests/ExtensionsTest.swift

@@ -84,7 +84,7 @@ final class ExtensionsTest: XCTestCase {
     do {
       let cipher = try AES(key: "secret0key000000".bytes.md5(), blockMode: ECB())
       let encrypted = try "".encryptToBase64(cipher: cipher)
-      let decrypted = try encrypted?.decryptBase64ToString(cipher: cipher)
+      let decrypted = try encrypted.decryptBase64ToString(cipher: cipher)
       XCTAssertEqual("", decrypted)
 
       XCTAssertThrowsError(try "".decryptBase64(cipher: cipher))