Skip to content

Software License Dongle for Julia

Julia binds through ccall, which is part of the language — so the binding has no dependencies outside Base. 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.

Reading a license

using KeyNubLicenseDongle

ctx = Context()
try
    dongle = open_dongle(ctx)          # first dongle, or open_dongle(ctx, serial)
    verify_genuine(dongle)             # throws unless genuine

    session(dongle) do s               # closed on every exit path
        license = read_record(s, "license")
    end
finally
    close(ctx)
endCode language: Julia (julia)

What you are actually protecting

Julia is the closest commercial neighbour to MATLAB — often the same engineering and scientific buyers, sometimes the same organisation. And as with MATLAB, if you sell a Julia package the valuable part is usually not the code. It is the correlation set, the fitted parameters, the validated coefficients, a proprietary model’s constants: the part that took years of measurement and that a competitor cannot regenerate from your documentation.

That makes the strong pattern easy here, because the thing worth protecting is already data rather than logic:

# Weak -- one deleted line.
is_genuine(dongle) || error("unlicensed")

# Strong -- the parameters only exist with the dongle present.
coefficients = app_decrypt(s, encrypted_blob_shipped_with_your_package)Code language: Julia (julia)

The do-block form of session closes the session even when an exception unwinds through it, so there is no cleanup path to forget.

Code

Runnable sample: julia/verify_and_read.jl. Binding source: bindings/julia. 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