File tree 4 files changed +9
-16
lines changed
4 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 1
- #if canImport(FoundationEssentials)
2
- import FoundationEssentials
3
- #else
4
- import Foundation
5
- #endif
6
-
7
1
@usableFromInline
8
2
struct Base64 {
9
3
@usableFromInline
Original file line number Diff line number Diff line change 1
- import Foundation
2
-
3
1
public struct Hasher {
4
2
@usableFromInline static let cipherText = Array ( " OrpheanBeholderScryDoubt " . utf8)
5
3
@usableFromInline static let maxSalt = 16
@@ -86,7 +84,15 @@ public struct Hasher {
86
84
87
85
var output = [ UInt8] ( )
88
86
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 ]
90
96
91
97
output += prefix
92
98
output += salt
Original file line number Diff line number Diff line change 1
- #if canImport(FoundationEssentials)
2
- import FoundationEssentials
3
- #else
4
- import Foundation
5
- #endif
6
-
7
1
struct Verifier {
8
2
private let version : BcryptVersion
9
3
private let hasher : Hasher
Original file line number Diff line number Diff line change 1
- import Foundation
2
1
import Testing
3
2
4
3
@testable import Bcrypt
You can’t perform that action at this time.
0 commit comments