Skip to content

Commit 7e80638

Browse files
committed
Define BCRYPT_SHA256_ALGORITHM correctly
1 parent 770bda9 commit 7e80638

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/TestingMacros/Support/CRC32.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ private func _crc32(_ bytes: some Sequence<UInt8>) -> UInt32 {
8282
#if os(Windows)
8383
/// The shared SHA-256 algorithm provider.
8484
private nonisolated(unsafe) let _sha256Algorithm: BCRYPT_ALG_HANDLE? = {
85-
var alg: BCRYPT_ALG_HANDLE?
86-
if 0/*STATUS_SUCCESS*/ == BCryptOpenAlgorithmProvider(&alg, "SHA256"/*BCRYPT_SHA256_ALGORITHM*/, nil, 0) {
87-
return alg
85+
let sha256AlgorithmName = "SHA256"
86+
return sha256AlgorithmName.withCString(encodedAs: UTF16.self) { sha256AlgorithmName in
87+
var alg: BCRYPT_ALG_HANDLE?
88+
if 0/*STATUS_SUCCESS*/ == BCryptOpenAlgorithmProvider(&alg, sha256AlgorithmName, nil, 0) {
89+
return alg
90+
}
91+
return nil
8892
}
89-
return nil
9093
}()
9194
#endif
9295

0 commit comments

Comments
 (0)