PDF
1FlutterContents ............................................................................................... 1Platform ......................................................................................... 2Example ............................................................................................... 4flutter create --org com.riguz --template=plugin encryptions使使cd encryptionsrm -rf ios examples/iosflutter create -i swift --org com.riguz .Dartclass Encryptions { static const MethodChannel _channel = const MethodChannel('encryptions'); static Future<Uint8List> aesEncrypt( Uint8List key, Uint8List iv, Uint8List value) async { return await _channel .invokeMethod("aesEncrypt", {"key": key, "iv": iv, "value": Platform2value}); }Platformioscd encryptions/example; flutter build ios --no-codesignpublic func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { let args = call.arguments as! [String: Any]; switch call.method { case "aesEncrypt", "aesDecrypt": let key = args["key"] as! FlutterStandardTypedData; let iv = args["iv"] as! FlutterStandardTypedData; let value = args["value"] as! FlutterStandardTypedData; do { let cipher = try handleAes(key: key.data, iv: iv.data, value: value.data, method: call.method); result(cipher); } catch { result(nil); }; // ... }}使#import "EncryptionsPlugin.h"#import "argon2.h"func argon2i(password: Data, salt: Data)-> Data { var outputBytes = [UInt8](repeating: 0, count: hashLength); password.withUnsafeBytes { passwordBytes in salt.withUnsafeBytes { saltBytes in argon2i_hash_raw(iterations, memory, parallelism, Platform3passwordBytes, password.count, saltBytes, salt.count, &outputBytes, hashLength); } } return Data(bytes: UnsafePointer<UInt8>(outputBytes), count: hashLength);}Androidcd encryptions/example; flutter build apkexternalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" }}add_library( argon2 SHARED argon2/src/argon2.c argon2/src/core.c argon2/src/blake2/blake2b.c argon2/src/encoding.c argon2/src/ref.c argon2/src/thread.c)add_library( argon2-binding SHARED argon2_binding.cpp)target_include_directories( argon2 PRIVATE argon2/include)target_include_directories( argon2-binding Example4 PRIVATE argon2/include)find_library( log-lib log)target_link_libraries( native-lib ${log-lib})target_link_libraries( argon2-binding argon2 ${log-lib})public final class Argon2 { static { System.loadLibrary("argon2-binding"); } // ... private native byte[] argon2iInternal(int iterations, int memory, int parallelism, final byte[] password, final byte[] salt, int hashLength); private native byte[] argon2dInternal(int iterations, int memory, int parallelism, final byte[] password, final byte[] salt, int hashLength);}Example Example5

HTML view coming soon.

Download PDF for the full formatted version.