Skip to content

Commit a76db3d

Browse files
committed
updated to support ffi 1.0.0
1 parent 4534df5 commit a76db3d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

.idea/libraries/Dart_Packages.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/argon2.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ class DArgon2 {
181181
encodedBytes.removeLast();
182182
}
183183
//Free all pointers
184-
free(hash);
185-
free(encoded);
186-
free(saltPointer);
187-
free(passPointer);
184+
malloc.free(hash);
185+
malloc.free(encoded);
186+
malloc.free(saltPointer);
187+
malloc.free(passPointer);
188188
if (DArgon2ErrorCode.values[result.abs()] != DArgon2ErrorCode.ARGON2_OK) {
189189
throw DArgon2Exception(
190-
Utf8.fromUtf8(LocalBinder.instance.getErrorMessage(result)),
190+
LocalBinder.instance.getErrorMessage(result).toDartString(),
191191
DArgon2ErrorCode.values[result.abs()]);
192192
}
193193
return DArgon2Result(hashBytes, encodedBytes);
@@ -239,17 +239,17 @@ class DArgon2 {
239239
{Argon2Type type = Argon2Type.i}) {
240240
//Create pointers to pass to the C method
241241
var passPointer = _setPtr(password);
242-
var hashPointer = Utf8.toUtf8(utf8.decode(encodedHash));
242+
var hashPointer = utf8.decode(encodedHash).toNativeUtf8();
243243
// var hashPointer = _setPtr(encodedHash);
244244
//Get the result
245245
var result = LocalBinder.instance
246246
.verifyHash(hashPointer, passPointer, password.length, type.index);
247247
//Free the pointers
248-
free(passPointer);
249-
free(hashPointer);
248+
malloc.free(passPointer);
249+
malloc.free(hashPointer);
250250
if (DArgon2ErrorCode.values[result.abs()] != DArgon2ErrorCode.ARGON2_OK) {
251251
throw DArgon2Exception(
252-
Utf8.fromUtf8(LocalBinder.instance.getErrorMessage(result)),
252+
LocalBinder.instance.getErrorMessage(result).toDartString(),
253253
DArgon2ErrorCode.values[result.abs()]);
254254
}
255255
return result == 0;
@@ -265,7 +265,7 @@ class DArgon2 {
265265
/// Returns a [Pointer] of type [Uint8] to be used for Argon2 computations.
266266
Pointer<Uint8> _setPtr(Iterable<int> iterable) {
267267
//Allocate a pointer in memory and set the values from the given list
268-
var p = allocate<Uint8>(count: Uint8List.fromList(iterable).length);
268+
var p = malloc<Uint8>(Uint8List.fromList(iterable).length);
269269
p.asTypedList(iterable.length).setAll(0, iterable);
270270
return p;
271271
}

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ environment:
77
sdk: '>=2.8.1 <3.0.0'
88

99
dependencies:
10-
ffi: '>=0.1.3 <1.0.0'
11-
convert: '>=2.1.1'
12-
meta: '>=1.2.3'
10+
ffi: '>=0.1.3 <2.0.0'
11+
convert: '>=2.1.1 <4.0.0'
12+
meta: '>=1.2.3 <2.0.0'
1313

1414
dev_dependencies:
1515
pedantic: ^1.9.0

0 commit comments

Comments
 (0)