using 1.0.1 using: ^1.0.1 copied to clipboard
This package provides a `Releasable` mixin to upgrade any class with automatic cleanup and finalization features, similar to C#'s `IDisposable` and Java's `AutoCloseable`. Extension methods enhance th [...]
import 'dart:convert';
import 'package:using/using.dart';
import 'impl/some_crypto_algorithm.dart';
import 'impl/utils.dart';
void main() {
// enable tracking
ReleasableTracker.enable();
final hash = SomeCryptoAlgorithm().use((crypto) {
Print.blue('hashing...');
crypto
..update(utf8.encode('password'))
..update(utf8.encode('salt'))
..update(utf8.encode('secret message'));
return crypto.digest();
});
Print.green('hash = ${dumpBytes(hash)}');
Print.std('');
// report
Print.std('Tracked count = ${ReleasableTracker.releasables.length}');
}