Browse Source

release 0.0.1

master
Herbert Poul 5 years ago
parent
commit
8c3cb65627
  1. 1
      argon2_ffi.iml
  2. 27
      example/lib/main.dart
  3. 18
      example/pubspec.lock
  4. 4
      example/pubspec.yaml
  5. 54
      lib/argon2_ffi.dart
  6. 11
      pubspec.lock
  7. 6
      pubspec.yaml

1
argon2_ffi.iml

@ -11,7 +11,6 @@
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/App.framework/flutter_assets/packages" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />

27
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<MyApp> {
final _argon2ffi = Argon2Ffi();
final _argon2ffi = Argon2FfiFlutter();
final random = Random();
String result;
@ -44,6 +42,25 @@ class _MyAppState extends State<MyApp> {
});
},
),
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)}';
});
},
),
],
),
),

18
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"

4
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

54
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<Utf8> Function(
Pointer<Uint8> key,
Uint32 keyLen,
Pointer<Uint8> 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<Utf8> Function(
Pointer<Uint8> key,
int keyLen,
Pointer<Uint8> 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<NativeFunction<Int32 Function(Int32, Int32)>>('native_add')
.asFunction();
argon2hash = argon2lib
.lookup<NativeFunction<Argon2HashNative>>('hp_argon2_hash')
.asFunction();
}
int addIt(int x, int y) => _nativeAdd(x, y);
}
// use argon2_ffi_base

11
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"

6
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

Loading…
Cancel
Save