diff --git a/SwiftyRSA/PublicKey.swift b/SwiftyRSA/PublicKey.swift index f2fea42..f2bca03 100644 --- a/SwiftyRSA/PublicKey.swift +++ b/SwiftyRSA/PublicKey.swift @@ -79,13 +79,13 @@ public class PublicKey: Key { public static func publicKeys(pemEncoded pemString: String) -> [PublicKey] { // If our regexp isn't valid, or the input string is empty, we can't move forward… - guard let publicKeyRegexp = publicKeyRegex, pemString.characters.count > 0 else { + guard let publicKeyRegexp = publicKeyRegex, pemString.count > 0 else { return [] } let all = NSRange( location: 0, - length: pemString.characters.count + length: pemString.count ) let matches = publicKeyRegexp.matches( @@ -102,8 +102,8 @@ public class PublicKey: Key { let match = result.rangeAt(1) #endif - let start = pemString.characters.index(pemString.startIndex, offsetBy: match.location) - let end = pemString.characters.index(start, offsetBy: match.length) + let start = pemString.index(pemString.startIndex, offsetBy: match.location) + let end = pemString.index(start, offsetBy: match.length) let range = Range(start.. String { func split(_ str: String, byChunksOfLength length: Int) -> [String] { - return stride(from: 0, to: str.characters.count, by: length).map { index -> String in + return stride(from: 0, to: str.count, by: length).map { index -> String in let startIndex = str.index(str.startIndex, offsetBy: index) let endIndex = str.index(startIndex, offsetBy: length, limitedBy: str.endIndex) ?? str.endIndex return String(str[startIndex..