commit 4f4557e4b64c4d4045546b2f21c2049bd1878a11
parent 9c6b802f19f0349c222084eae722101487373220
Author: Terry Yiu <963907+tyiu@users.noreply.github.com>
Date: Mon, 2 Jan 2023 00:06:52 -0500
Replace deprecated Data.withUnsafeMutableBytes call
Closes: #214
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift
@@ -448,7 +448,7 @@ func hex_encode(_ data: Data) -> String {
func random_bytes(count: Int) -> Data {
var data = Data(count: count)
_ = data.withUnsafeMutableBytes { mutableBytes in
- SecRandomCopyBytes(kSecRandomDefault, count, mutableBytes)
+ SecRandomCopyBytes(kSecRandomDefault, count, mutableBytes.baseAddress!)
}
return data
}
diff --git a/damusTests/damusTests.swift b/damusTests/damusTests.swift
@@ -33,6 +33,13 @@ class damusTests: XCTestCase {
}
}
+ func testRandomBytes() {
+ let bytes = random_bytes(count: 32)
+
+ print("testRandomBytes \(hex_encode(bytes))")
+ XCTAssertEqual(bytes.count, 32)
+ }
+
func testParseMentionWithMarkdown() {
let md = """
Testing markdown in damus