Swift

一:加密(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))

        }

 

上一篇:标志位和中断位的区别:USART_ClearFlag和USART_ClearITPendingBit


下一篇:go 语言图片像素点处理