Dart reaches the dongle through dart:ffi, which is part of the language, and loads the native library at run time — so the package is pure Dart with no plugin glue and no build step, the same in a command-line program and in a Flutter desktop application on Windows, Linux or macOS. For a licensing component that is the right shape: nothing sits in the path of the check that a customer could substitute for something more agreeable.
dart pub add keynub_licdongleCode language: Dart (dart)
Reading a license
import 'package:keynub_licdongle/keynub_licdongle.dart';
final ctx = Context();
final dongle = ctx.open(); // first dongle, or ctx.open(serial: ...)
dongle.verifyGenuine(); // throws unless genuine
final license = dongle.withSession((s) => // closed on every exit path
s.readRecord('license'));
dongle.close();
ctx.close();Code language: Dart (dart)
What you are actually protecting
A Flutter application ships as an ahead-of-time snapshot, and a Dart command-line tool as a native executable. Both are readable enough for a determined person to find if (!dongle.isGenuine) exit(1) and remove it: one branch, one patch. Obfuscation only raises the effort.
What cannot be patched away is data the program needs and only the dongle can decrypt. Seal it once with a developer dongle, ship only the sealed form, and the program has no copy to fall back on:
// Weak -- one deleted line.
if (!dongle.isGenuine) exit(1);
// Strong -- the parameters only exist with the dongle present.
final parameters = session.appDecrypt(sealedBlobShippedWithTheApp);Code language: Dart (dart)
withSession closes the session even when an exception unwinds through it, so there is no cleanup path to forget. Failures are LicenseDongleErrors with a status (Status.noDevice, notGenuine, authRequired, …), so a catch branches on what happened.
Code
Runnable sample: dart/bin/verify_and_read.dart. Binding source: bindings/dart. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.
All supported languages · All industries · Buy a KeyNub · Ask us something