-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move md5 string extension to own file
- Loading branch information
Showing
3 changed files
with
21 additions
and
39 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
Source/SwiftLintFramework/Extensions/Configuration+Cache.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#if canImport(CommonCrypto) | ||
import CommonCrypto | ||
#else | ||
import CryptoSwift | ||
#endif | ||
import Foundation | ||
|
||
#if canImport(CommonCrypto) | ||
extension String { | ||
internal func md5() -> String { | ||
let context = UnsafeMutablePointer<CC_MD5_CTX>.allocate(capacity: 1) | ||
var digest = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) | ||
CC_MD5_Init(context) | ||
CC_MD5_Update(context, self, CC_LONG(lengthOfBytes(using: .utf8))) | ||
CC_MD5_Final(&digest, context) | ||
context.deallocate() | ||
return digest.reduce(into: "") { $0.append(String(format: "%02x", $1)) } | ||
} | ||
} | ||
#endif |
21 changes: 1 addition & 20 deletions
21
Source/SwiftLintFramework/Reporters/CodeClimateReporter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters