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 55
66
77import Foundation
8- import Security
98
109/// A class to wrap around Salts in argon2. allowing cryptographically secure generation of salts as well as utilization of premade salts
1110public class Salt {
@@ -30,15 +29,7 @@ public class Salt {
3029 - Returns: A `Salt` object containing a random byte array of the specified length
3130 */
3231 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 ) } )
4233 return Salt ( bytes: Data ( bytes) )
4334 }
4435}
You can’t perform that action at this time.
0 commit comments