What is a software license key system? How keys are checked
A software license key system makes the keys for the program you sell, checks them when it starts and while it runs, and stops keys you cancel
A license key is the code you give each buyer. The license key system is everything around it: the place where keys are made, the check your program runs before it opens, and the record of which key runs on which computer. This article explains how these systems work in general, with PWF Auth as the worked example, so you can judge any of them, including one you build yourself
The key and the license are two different things
The key is the string the customer types, like PWF-8K3D-7HZE-XW4N. The license is the set of rights behind it: which program, until when, on how many PCs, and whether it is paused or banned. A good system keeps those rights on its own side, so you can extend, pause or end a license without sending the customer a new key
The usual license models
- A trial runs for a set number of days and then asks for a key
- A time-limited license works for hours, days, a month or a year and stops when the time is up, unless it is renewed
- A lifetime license has no end date
- A node-locked license works on one computer, or on a fixed number of them, recognised by a hardware ID
- A floating license shares a pool of seats between machines, so any PC may use it while a seat is free
Most software sold by small teams uses time-limited or lifetime keys, locked to one PC. PWF Auth makes keys from hours to lifetime and locks each one to the first PC that signs in, with up to 100 PCs per key when you allow more
How a key gets checked
There are two ways to check a key, and the difference decides what you can do after the sale
Offline: the key carries its own proof
The key, or a license file, holds the rights and a digital signature. Your program checks the signature with a public key built into it, and no server is asked. That works without internet, but it has a cost: a key you want to cancel keeps working, because the program never asks anyone, and a key copied to another PC opens there too unless its license file was made for one machine
Online: the program asks a server
The program sends the key and the PC's hardware ID to a license server, and the server answers with the license or a refusal. You can ban a key at any moment, see where it runs, and refuse a second PC. The price is a connection to the internet, and an answer that must be protected, or a fake server on the buyer's own PC could simply say yes
Online, and again while the program runs
A check when the program starts is not enough on its own: a copy left open keeps running after you ban its key. So online systems also check in while the program runs. PWF Auth's SDKs send this heartbeat every 30 seconds, so a ban, a pause or an expiry closes the program within 30 seconds, and a copy that misses three check-ins in a row (about 90 seconds without an answer) ends its own session. Without that rule, blocking the license server in a firewall would keep a banned copy alive
Locking a key to one computer
The hardware ID is a value read from the machine that stays the same through reboots and updates. On Windows, PWF Auth's packages use the MachineGuid that Windows keeps for its cryptography. The first sign-in binds the key to that PC, and any other PC is refused. When a customer really changes computer, the key is moved: by you, by the customer from inside your program, or on a portal, by the rules you set. What is an HWID lock? explains it in detail
Keeping the answer honest
An online check is only as good as the answer it gets. A reply that simply says valid: true over the network can be faked by anyone who controls that PC. A sound system closes the usual ways in:
- Requests and replies are encrypted and signed with a secret that belongs to your app
- Every message carries a timestamp, and an old one is refused, so a recorded "valid" reply can't be played back later
- The server also signs each reply with its own private key, and the client checks that signature with the public key built into it, so even someone who knows your app secret can't pose as the server
PWF Auth does all three: AES-256 and HMAC-SHA256 from the app secret, a five-minute limit on timestamps, and an RSA signature that the C# and VB.NET, Python and C++ SDKs check. How protection works has the details
What a license system can't do
No license system makes a program impossible to crack. Someone who has your program can change it so the check never runs. What a good system does is make the easy attacks useless: a shared key won't open on another PC, a refunded key stops working, a fake server gets nowhere, and you can see who runs your program. Make the rest harder with an obfuscated build, and ship updates you can make required, so old cracked builds age out
Build it or use a service
Building your own means a server and a database, the encryption on both sides, a client for each language you ship in, a panel to make and manage keys, and ways to move keys, pause them and deliver them after a sale. It is a real project, and it keeps needing work after launch. A service gives you that part ready, so you write the few lines in your program and manage keys from a panel
PWF Auth is such a service: keys locked to a PC, the 30-second heartbeat, customer accounts, resellers, store connections and updates, with SDKs for C#, VB.NET, Python, Node.js and C++ and a REST API for any other language. Getting started takes you from a new account to a protected app in six steps