diff --git a/argon2_ffi.iml b/argon2_ffi.iml index 9a198d2..73e7ebd 100644 --- a/argon2_ffi.iml +++ b/argon2_ffi.iml @@ -11,7 +11,6 @@ - diff --git a/example/lib/main.dart b/example/lib/main.dart index 50c14d3..684c9a4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,10 +1,8 @@ +import 'dart:convert'; import 'dart:math'; +import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter/services.dart'; -import 'package:argon2_ffi/argon2_ffi.dart'; void main() => runApp(MyApp()); @@ -14,7 +12,7 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - final _argon2ffi = Argon2Ffi(); + final _argon2ffi = Argon2FfiFlutter(); final random = Random(); String result; @@ -44,6 +42,25 @@ class _MyAppState extends State { }); }, ), + RaisedButton( + child: Text('hash stuff'), + onPressed: () { + final args = Argon2Arguments( + utf8.encode('abc'), + utf8.encode('abc'), + 1024, + 2, + 32, + 2, + 0, + 1, + ); + final hash = _argon2ffi.argon2(args); + setState(() { + result = 'argon2 hash: ${base64.encode(hash)}'; + }); + }, + ), ], ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index dc7c71f..1802d72 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -8,6 +8,15 @@ packages: relative: true source: path version: "0.0.1" + argon2_ffi_base: + dependency: "direct main" + description: + path: "." + ref: a867d30e77521012fd68af0208ec9ccc57127d86 + resolved-ref: a867d30e77521012fd68af0208ec9ccc57127d86 + url: "https://github.com/hpoul/argon2_ffi_base.git" + source: git + version: "0.0.1" async: dependency: transitive description: @@ -43,13 +52,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.12" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.3" fake_async: dependency: transitive description: @@ -164,4 +166,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=2.7.0 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 2017837..062cc79 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,10 +9,6 @@ dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 - dev_dependencies: flutter_test: sdk: flutter diff --git a/lib/argon2_ffi.dart b/lib/argon2_ffi.dart index d66ce89..829e625 100644 --- a/lib/argon2_ffi.dart +++ b/lib/argon2_ffi.dart @@ -1,53 +1 @@ -import 'dart:async'; -import 'dart:ffi'; -import 'dart:io'; - -import 'package:ffi/ffi.dart'; -import 'package:flutter/services.dart'; - -typedef Argon2HashNative = Pointer Function( - Pointer key, - Uint32 keyLen, - Pointer salt, - Uint32 saltlen, - Uint32 m_cost, // memory cost - Uint32 t_cost, // time cost (number iterations) - Uint32 parallelism, - IntPtr hashlen, - Uint8 type, - Uint32 version, -); - -typedef Argon2Hash = Pointer Function( - Pointer key, - int keyLen, - Pointer salt, - int saltlen, - int m_cost, // memory cost - int t_cost, // time cost (number iterations) - int parallelism, - int hashlen, - int type, - int version, -); - -class Argon2Ffi { - int Function(int x, int y) _nativeAdd; - Argon2Hash argon2hash; - - Argon2Ffi() { - final argon2lib = Platform.isAndroid - ? DynamicLibrary.open('libargon2_ffi.so') - : Platform.isLinux - ? DynamicLibrary.open('libargon2_ffi_plugin.so') - : DynamicLibrary.executable(); - _nativeAdd = argon2lib - .lookup>('native_add') - .asFunction(); - argon2hash = argon2lib - .lookup>('hp_argon2_hash') - .asFunction(); - } - - int addIt(int x, int y) => _nativeAdd(x, y); -} +// use argon2_ffi_base diff --git a/pubspec.lock b/pubspec.lock index 870fa7e..6f3c0a7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,15 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + argon2_ffi_base: + dependency: "direct main" + description: + path: "." + ref: a867d30e77521012fd68af0208ec9ccc57127d86 + resolved-ref: a867d30e77521012fd68af0208ec9ccc57127d86 + url: "https://github.com/hpoul/argon2_ffi_base.git" + source: git + version: "0.0.1" async: dependency: transitive description: @@ -150,4 +159,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=2.7.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 01beb43..77921da 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,6 @@ name: argon2_ffi description: A new flutter plugin project. version: 0.0.1 -author: -homepage: environment: sdk: ">=2.1.0 <3.0.0" @@ -10,6 +8,10 @@ environment: dependencies: flutter: sdk: flutter + argon2_ffi_base: + git: + url: https://github.com/hpoul/argon2_ffi_base.git + ref: a867d30e77521012fd68af0208ec9ccc57127d86 ffi: ^0.1.3 ffi_helper: ^1.4.0