Flutter ffi library for argon2 implementation
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.

61 lines
1.4 KiB

5 years ago
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
5 years ago
import 'package:argon2_ffi_base/argon2_ffi_base.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
5 years ago
final _argon2ffi = Argon2FfiFlutter();
final random = Random();
String? result;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: <Widget>[
Text('Result: $result\n'),
ElevatedButton(
5 years ago
child: Text('hash stuff'),
onPressed: () {
final args = Argon2Arguments(
utf8.encode('abc') as Uint8List,
utf8.encode('abc') as Uint8List,
5 years ago
1024,
2,
32,
2,
0,
1,
);
final hash = _argon2ffi.argon2(args);
setState(() {
result = 'argon2 hash: ${base64.encode(hash)}';
});
},
),
],
),
),
);
}
}