fix(ios): key length in bits

This commit is contained in:
Hugo Pointcheval 2023-04-04 23:21:39 +02:00
parent 68217ac4b9
commit 5be6296829
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC

View File

@ -31,7 +31,8 @@ public class NativeCrypto: NSObject, NativeCryptoAPI {
func generateSecureRandom(length: Int64) throws -> FlutterStandardTypedData? {
let lengthInt = Int(truncatingIfNeeded: length)
let symmetricKey = SymmetricKey.init(size: SymmetricKeySize(bitCount: lengthInt / 8))
let bitCount = lengthInt * 8
let symmetricKey = SymmetricKey.init(size: SymmetricKeySize(bitCount: bitCount))
let bytes = symmetricKey.withUnsafeBytes
{
return Data(Array($0))