Skip to content

Commit d62aa93

Browse files
committed
Remove Foundation
1 parent 2cb15c1 commit d62aa93

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

Sources/Bcrypt/Base64.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#if canImport(FoundationEssentials)
2-
import FoundationEssentials
3-
#else
4-
import Foundation
5-
#endif
6-
71
@usableFromInline
82
struct Base64 {
93
@usableFromInline

Sources/Bcrypt/Hasher.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Foundation
2-
31
public struct Hasher {
42
@usableFromInline static let cipherText = Array("OrpheanBeholderScryDoubt".utf8)
53
@usableFromInline static let maxSalt = 16
@@ -86,7 +84,15 @@ public struct Hasher {
8684

8785
var output = [UInt8]()
8886

89-
let prefix = version.identifier + [UInt8]("\(String(format: "%02d", cost))$".utf8)
87+
let cost: [UInt8] =
88+
switch cost {
89+
case 0...9:
90+
[0x30, UInt8(cost + 0x30)]
91+
default:
92+
[UInt8(cost / 10 + 0x30), UInt8(cost % 10 + 0x30)]
93+
}
94+
95+
let prefix = version.identifier + cost + [36]
9096

9197
output += prefix
9298
output += salt

Sources/Bcrypt/Verifier.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#if canImport(FoundationEssentials)
2-
import FoundationEssentials
3-
#else
4-
import Foundation
5-
#endif
6-
71
struct Verifier {
82
private let version: BcryptVersion
93
private let hasher: Hasher

Tests/BcryptTests/BcryptTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Foundation
21
import Testing
32

43
@testable import Bcrypt

0 commit comments

Comments
 (0)