I'm getting the warning: 'withUnsafeBytes' is deprecated: use withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
instead
for the following code:
func keyForPassword(_ inPassword:String, salt:Data, keySettings:SOSCryptorKeyDerivationSettings) -> Data {
let size = Int(keySettings.keySize)
var derivedKey = Data(count: size)
let passwordLength = size_t(inPassword.lengthOfBytes(using: String.Encoding.utf8))
derivedKey.withUnsafeMutableBytes { (ptr:UnsafeMutablePointer<UInt8>) -> Void in
_ = CCKeyDerivationPBKDF(CCPBKDFAlgorithm(keySettings.PBKDFAlgorithm), NSString(string: inPassword).utf8String, size_t(passwordLength), (salt as NSData).bytes.bindMemory(to: UInt8.self, capacity: salt.count), size_t(salt.count), CCPseudoRandomAlgorithm(keySettings.PRF), uint(keySettings.rounds), ptr, size_t(size));
}
return derivedKey
}
I cannot figure out how to resolve this issue.