diff --git a/analysis_options.yaml b/analysis_options.yaml index fff9bb4..f7c7e75 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,14 +1,9 @@ -analyzer: - strong-mode: true - linter: rules: - camel_case_types - empty_constructor_bodies - always_declare_return_types - - camel_case_types - constant_identifier_names - - empty_constructor_bodies - implementation_imports - library_names - library_prefixes @@ -18,7 +13,6 @@ linter: - package_prefixed_library_names - prefer_is_not_empty - slash_for_doc_comments - - super_goes_last - type_annotate_public_apis - type_init_formals - unnecessary_getters_setters @@ -34,14 +28,12 @@ linter: - iterable_contains_unrelated_type - list_remove_unrelated_type - test_types_in_equals - - throw_in_finally - valid_regexps - annotate_overrides - avoid_init_to_null - avoid_return_types_on_setters - await_only_futures - empty_catches - - prefer_is_not_empty - sort_constructors_first - sort_unnamed_constructors_first - unawaited_futures diff --git a/lib/pbkdf2.dart b/lib/pbkdf2.dart index 24e40ca..1e45694 100644 --- a/lib/pbkdf2.dart +++ b/lib/pbkdf2.dart @@ -13,18 +13,18 @@ class PBKDF2 { /// Creates instance capable of generating a key. /// /// [hashAlgorithm] defaults to [sha256]. - PBKDF2({Hash hashAlgorithm}) { + PBKDF2({Hash? hashAlgorithm}) { this.hashAlgorithm = hashAlgorithm ?? sha256; } - Hash get hashAlgorithm => _hashAlgorithm; - set hashAlgorithm(Hash algorithm) { + Hash? get hashAlgorithm => _hashAlgorithm; + set hashAlgorithm(Hash? algorithm) { _hashAlgorithm = algorithm; - _blockSize = _hashAlgorithm.convert([1, 2, 3]).bytes.length; + _blockSize = _hashAlgorithm!.convert([1, 2, 3]).bytes.length; } - Hash _hashAlgorithm; - int _blockSize; + Hash? _hashAlgorithm; + late int _blockSize; /// Hashes a [password] with a given [salt]. /// @@ -40,7 +40,7 @@ class PBKDF2 { } var numberOfBlocks = (keyLength / _blockSize).ceil(); - var hmac = new Hmac(hashAlgorithm, utf8.encode(password)); + var hmac = new Hmac(hashAlgorithm!, utf8.encode(password)); var key = new ByteData(keyLength); var offset = 0; @@ -90,7 +90,7 @@ class PBKDF2Exception implements Exception { class _XORDigestSink extends Sink { _XORDigestSink(ByteData inputBuffer, Hmac hmac) { - lastDigest = hmac.convert(inputBuffer.buffer.asUint8List()).bytes; + lastDigest = hmac.convert(inputBuffer.buffer.asUint8List()).bytes as Uint8List; bytes = new ByteData(lastDigest.length) ..buffer.asUint8List().setRange(0, lastDigest.length, lastDigest); } @@ -109,12 +109,12 @@ class _XORDigestSink extends Sink { return hashSink.bytes.buffer.asUint8List(); } - ByteData bytes; - Uint8List lastDigest; + late ByteData bytes; + late Uint8List lastDigest; @override void add(Digest digest) { - lastDigest = digest.bytes; + lastDigest = digest.bytes as Uint8List; for (var i = 0; i < digest.bytes.length; i++) { bytes.setUint8(i, bytes.getUint8(i) ^ lastDigest[i]); } diff --git a/pubspec.yaml b/pubspec.yaml index ba6692e..b523b31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,10 +5,10 @@ homepage: https://github.com/stablekernel/dart-password-hash description: PBKDF2 password hashing utility environment: - sdk: ">=2.0.0 <3.0.0" + sdk: '>=2.12.0-133.7.beta <3.0.0' dependencies: - crypto: ^2.0.0 + crypto: ^3.0.0 dev_dependencies: test: ^1.3.0