Skip to content

Commit

Permalink
Native cipher code for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
omert08 committed Apr 15, 2021
1 parent a4a4662 commit a2f276d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ios/Classes/SwiftEspSoftapProvisioningPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ import Flutter
import UIKit

public class SwiftEspSoftapProvisioningPlugin: NSObject, FlutterPlugin {
private var cryptoAES: CryptoAES?
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "esp_softap_provisioning", binaryMessenger: registrar.messenger())
let instance = SwiftEspSoftapProvisioningPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {

if call.method == "init" {
let args = call.arguments as! NSDictionary
let key = args["key"] as! FlutterStandardTypedData
let iv = args["iv"] as! FlutterStandardTypedData
cryptoAES = CryptoAES(key: key.data, iv: iv.data)
result(true)
} else if call.method == "crypt" {
let args = call.arguments as! NSDictionary
let data = args["data"] as! FlutterStandardTypedData
guard let cryptoAES = self.cryptoAES else {
return
}
let ret = cryptoAES.encrypt(data: data.data)

result(FlutterStandardTypedData(bytes: ret!))
}
result("iOS " + UIDevice.current.systemVersion)
}

}

0 comments on commit a2f276d

Please sign in to comment.