From 4c9464b4a21dd558a9b1f4a4ed603bb67dcbc773 Mon Sep 17 00:00:00 2001 From: Jayson Rhynas Date: Thu, 14 Nov 2024 00:05:49 -0500 Subject: [PATCH] Convert bytes directly to Data instead of UnsafePointer API (#83) * Convert bytes directly to Data instead of UnsafePointer API Using a pointer to an array created via the UnsafePointer initializer is undefined and isn't guaranteed to be valid. * Use non-deprecated initializer for Data --- Sources/CryptorRSA/CryptorRSAUtilities.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CryptorRSA/CryptorRSAUtilities.swift b/Sources/CryptorRSA/CryptorRSAUtilities.swift index 1d6532c..eff4229 100644 --- a/Sources/CryptorRSA/CryptorRSAUtilities.swift +++ b/Sources/CryptorRSA/CryptorRSAUtilities.swift @@ -286,7 +286,7 @@ public extension CryptorRSA { index += 1 let strippedKeyBytes = [UInt8](byteArray[index...keyData.count - 1]) - let data = Data(bytes: UnsafePointer(strippedKeyBytes), count: keyData.count - index) + let data = Data(strippedKeyBytes) return data }