File tree Expand file tree Collapse file tree 4 files changed +9
-16
lines changed
Expand file tree Collapse file tree 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-
71@usableFromInline
82struct Base64 {
93 @usableFromInline
Original file line number Diff line number Diff line change 1- import Foundation
2-
31public 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
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-
71struct Verifier {
82 private let version : BcryptVersion
93 private let hasher : Hasher
Original file line number Diff line number Diff line change 1- import Foundation
21import Testing
32
43@testable import Bcrypt
You can’t perform that action at this time.
0 commit comments