Update dart with new pbkdf2
This commit is contained in:
parent
5e30e36550
commit
ee9490d3a4
@ -4,7 +4,6 @@ import 'dart:developer';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:native_crypto/symmetric_crypto.dart';
|
||||
import 'package:native_crypto/exceptions.dart';
|
||||
@ -53,7 +52,7 @@ class _MyAppState extends State<MyApp> {
|
||||
if (password.isEmpty) {
|
||||
output = 'Password is empty';
|
||||
} else {
|
||||
key = await KeyGenerator().pbkdf2(password, 'salt');
|
||||
key = await KeyGenerator().pbkdf2(password, 'salt', algorithm: 'sha1');
|
||||
output = 'Key successfully derived.';
|
||||
}
|
||||
setState(() {
|
||||
|
@ -21,7 +21,7 @@ class NativeCrypto {
|
||||
///
|
||||
/// [keyLength] is in Bytes.
|
||||
/// It returns an `Uint8List`.
|
||||
Future<Uint8List> pbkdf2(String password, String salt, {int keyLength: 32, int iteration: 10000}) async {
|
||||
Future<Uint8List> pbkdf2(String password, String salt, {int keyLength: 32, int iteration: 10000, String algorithm: 'sha256'}) async {
|
||||
Uint8List key;
|
||||
try {
|
||||
key = await _channel.invokeMethod('pbkdf2', <String, dynamic>{
|
||||
@ -29,6 +29,7 @@ class NativeCrypto {
|
||||
'salt': salt,
|
||||
'keyLength': keyLength,
|
||||
'iteration': iteration,
|
||||
'algorithm': algorithm,
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
throw e;
|
||||
|
@ -59,10 +59,10 @@ class KeyGenerator {
|
||||
///
|
||||
/// `keyLength` is in Bytes.
|
||||
/// It returns an `Uint8List`.
|
||||
Future<Uint8List> pbkdf2(String password, String salt, {int keyLength: 32, int iteration: 10000}) async {
|
||||
Future<Uint8List> pbkdf2(String password, String salt, {int keyLength: 32, int iteration: 10000, String algorithm: 'sha256'}) async {
|
||||
Uint8List key;
|
||||
try {
|
||||
key = await NativeCrypto().pbkdf2( password, salt, keyLength: keyLength, iteration: iteration);
|
||||
key = await NativeCrypto().pbkdf2( password, salt, keyLength: keyLength, iteration: iteration, algorithm: algorithm);
|
||||
log("PBKDF2 KEY LENGTH: ${key.length}", name: TAG_DEBUG);
|
||||
} on PlatformException catch (e) {
|
||||
log(e.message, name: TAG_ERROR);
|
||||
|
Loading…
x
Reference in New Issue
Block a user