Skip to content

Commit fc199e4

Browse files
authored
Update to new SHA256() API in the core (#27)
* Update to new SHA256() API in the core * Move to Xcode 11.4 to get MacOS 10.15 (which should have CryptoKit)
1 parent 9d1bbe7 commit fc199e4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode11.2
2+
osx_image: xcode11.4
33

44
env:
55
- ACTION=test PLATFORM=Mac DESTINATION='platform=OS X'

Sources/SourceParsingFramework/Utilities/Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension String {
2222

2323
/// The SHA256 value of this String.
2424
public var shortSHA256Value: String {
25-
return SHA256(self).digestString().substring(with: NSRange(location: 0, length: 20))!
25+
return SHA256().hash(self).hexadecimalRepresentation.substring(with: NSRange(location: 0, length: 20))!
2626
}
2727

2828
/// Return the same String with the first character lowercased.

Tests/SourceParsingFrameworkTests/Utilities/ExtensionsTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class ExtensionsTests: AbstractSourceParsingTests {
3030
dirPath = String(filePath.prefix(upTo: index))
3131
}
3232

33+
func test_sha256_verifyResults() {
34+
let input = "Some random string"
35+
let sha256 = input.shortSHA256Value
36+
XCTAssertEqual(sha256, "7e2ab276842ae9fb52ae")
37+
}
38+
3339
func test_isDirectory_verifyResults() {
3440
XCTAssertFalse(filePath.isDirectory)
3541
XCTAssertTrue(dirPath.isDirectory)

0 commit comments

Comments
 (0)