Browse Source

Fix warnings with Swift 5.8

There are a few warnings when compiling `main` with Swift 5.8:

```
Sources/CryptoSwift/Scrypt.swift:124:7 'assign(from:count:)' is deprecated: renamed to 'update(from:count:)'
Sources/CryptoSwift/String+Extension.swift:21:5 Instance method 'data(using:allowLossyConversion:)' cannot be used in an '@inlinable' function because 'Foundation' was not imported by this file; this is an error in Swift 6
Sources/CryptoSwift/String+Extension.swift:21:24 Struct 'Encoding' cannot be used in an '@inlinable' function because 'Foundation' was not imported by this file; this is an error in Swift 6
Sources/CryptoSwift/String+Extension.swift:21:33 Static property 'utf8' cannot be used in an '@inlinable' function because 'Foundation' was not imported by this file; this is an error in Swift 6
```

This fixes them all while continuing to support previous Swift compiler
versions.
JP Simard 2 năm trước cách đây
mục cha
commit
6b6e4a34ea

+ 4 - 0
Sources/CryptoSwift/Scrypt.swift

@@ -121,7 +121,11 @@ private extension Scrypt {
 
     /* 1: X <-- B */
     let typedBlock = block.assumingMemoryBound(to: UInt32.self)
+#if compiler(>=5.8)
+    X.update(from: typedBlock, count: 32 * self.r)
+#else
     X.assign(from: typedBlock, count: 32 * self.r)
+#endif
 
     /* 2: for i = 0 to N - 1 do */
     for i in stride(from: 0, to: self.N, by: 2) {

+ 2 - 0
Sources/CryptoSwift/String+Extension.swift

@@ -13,6 +13,8 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
+import Foundation
+
 /** String extension */
 extension String {