You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Web3Core/Utility/Data+Extension.swift
+8-10Lines changed: 8 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -42,25 +42,23 @@ public extension Data {
42
42
}
43
43
44
44
/**
45
-
Generates an array of random bytes with the specified length.
46
-
45
+
Generates an array of random bytes of the specified length.
46
+
This function uses `SecRandomCopyBytes` to generate random bytes returning it as a `Data` object.
47
+
If an error occurs during random bytes generation, the function returns `nil`.
48
+
Error occurs only if `SecRandomCopyBytes` returns status that is not `errSecSuccess`.
49
+
See [all status codes](https://developer.apple.com/documentation/security/1542001-security_framework_result_codes) for possible error reasons.
50
+
Note: in v4 of web3swift this function will be deprecated and a new implementation will be provided that will throw occured error.
47
51
- Parameter length: The number of random bytes to generate.
48
52
49
-
- Returns: An optional `Data` object containing the generated random bytes, or `nil` if an error occurs during generation.
50
-
- Note: This function uses `SecRandomCopyBytes` to generate random bytes and shuffles the resulting array before returning it as a `Data` object. If an error occurs during random bytes generation, the function returns `nil`.
53
+
- Returns: optional `Data` object containing the generated random bytes, or `nil` if an error occured during generation.
0 commit comments