一:加密(PBKDF2 , AES)
1,[UInt8] :
将Data数据转换为[UInt8](bytes字节数组)
//获取安全随机数 static func getRandomSalt(length: Int) -> (Data, OSStatus){ var data = Data(count: length) var local = data let result = local.withUnsafeMutableBytes { mutableBytes in SecRandomCopyBytes(kSecRandomDefault, data.count, mutableBytes) } // (数据,结果) return (local,result) }
// Data -> [UInt8] 将Data数据转换为[UInt8](bytes字节数组) let ivbytes = local.withUnsafeBytes { [UInt8](UnsafeBufferPointer(start: $0, count: local.count)) }