Skip to content

Instantly share code, notes, and snippets.

@bergusman
Created September 9, 2021 16:56
Show Gist options
  • Save bergusman/f2c3cad3d1a937e5d43f648973ef496f to your computer and use it in GitHub Desktop.
Save bergusman/f2c3cad3d1a937e5d43f648973ef496f to your computer and use it in GitHub Desktop.
Security
var bytes = [UInt8](repeating: 0, count: 8)
var status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
if status == errSecSuccess {
print(bytes)
} else {
if let message = SecCopyErrorMessageString(status, nil) {
print("Error(\(status): \(message)")
} else {
print("Error: \(status)")
}
}
var bytes2: UInt64 = 0
status = SecRandomCopyBytes(kSecRandomDefault, 8, &bytes2)
print(status, bytes2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment