Replace deprecated Data.withUnsafeMutableBytes call

Closes: #214
This commit is contained in:
tyiu authored and William Casarin committed 2023-01-02 08:19:47 -08:00
1 parent 9c6b802f19
commit 4f4557e4b6
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -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
}
+7
View File
@@ -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