File tree Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change 5
5
6
6
7
7
import Foundation
8
- import Security
9
8
10
9
/// A class to wrap around Salts in argon2. allowing cryptographically secure generation of salts as well as utilization of premade salts
11
10
public class Salt {
@@ -30,15 +29,7 @@ public class Salt {
30
29
- Returns: A `Salt` object containing a random byte array of the specified length
31
30
*/
32
31
public static func newSalt( length: Int = 16 ) -> Salt {
33
- // Set a byte array
34
- var bytes = [ UInt8] ( repeating: 0 , count: length)
35
- // Set random generated numbers to the byte array
36
- let status = SecRandomCopyBytes ( kSecRandomDefault, bytes. count, & bytes)
37
- // Ensure the copy was a success
38
- if status != errSecSuccess {
39
- fatalError ( " SecRandomCopyBytes failed with error code: \( status) " )
40
- }
41
- // Return the salt
32
+ let bytes = Array ( ( 0 ..< length) . map { _ in UInt8 . random ( in: 0 ... 255 ) } )
42
33
return Salt ( bytes: Data ( bytes) )
43
34
}
44
35
}
You can’t perform that action at this time.
0 commit comments