Files
RediStack/Tests/RediStackTests/ExtensionTests.swift
Nathan Harris bf887a9d19 Replace SHA1 Implementation
Motivation:

The `CNIOSHA1` module from SwiftNIO is an implementation detail. The fact that we were able to import and build the project with it is a bug/feature of Swift Package Manager.

Should the Swift ecosystem standardize on an implementation, that will replace the one we have chosen later.

Modifications:

Use the SHA1 native Swift implementation from CryptoSwift by reproducing the necessary code in our project.
Updates to the appropriate files to provide attribution to CryptoSwift have been included.

Result:
A reliable and pure Swift implementation of the SHA1 digest algorithm in the project for the sake of Lua script cache hashing.
2020-02-05 21:00:37 -08:00

28 lines
800 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the RediStack open source project
//
// Copyright (c) 2019 RediStack project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of RediStack project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
@testable import RediStack
import XCTest
final class ExtensionTests: XCTestCase {
func testString_sha1() {
let str = "Hello String Test"
guard let hash = str.sha1 else {
XCTFail()
return
}
XCTAssertEqual(hash, "9c0015411ab9150a115d4730dc2c940d94913402")
}
}