You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
873 B
31 lines
873 B
import 'dart:async'; |
|
import 'dart:ffi'; |
|
import 'dart:io'; |
|
|
|
import 'package:ffi/ffi.dart'; |
|
import 'package:flutter/services.dart'; |
|
|
|
typedef HashStuff = Pointer<Utf8> Function(Pointer<Utf8> str); |
|
|
|
class Argon2Ffi { |
|
static const MethodChannel _channel = const MethodChannel('argon2_ffi'); |
|
|
|
int Function(int x, int y) _nativeAdd; |
|
HashStuff _hashStuff; |
|
|
|
Argon2Ffi() { |
|
final argon2lib = Platform.isAndroid |
|
? DynamicLibrary.open('libargon2_ffi.so') |
|
: DynamicLibrary.executable(); |
|
_nativeAdd = argon2lib |
|
.lookup<NativeFunction<Int32 Function(Int32, Int32)>>('native_add') |
|
.asFunction(); |
|
_hashStuff = |
|
argon2lib.lookup<NativeFunction<HashStuff>>('hashStuff').asFunction(); |
|
} |
|
|
|
int addIt(int x, int y) => _nativeAdd(x, y); |
|
|
|
String hashStuff(String password) => |
|
Utf8.fromUtf8(_hashStuff(Utf8.toUtf8(password))); |
|
}
|
|
|