DLMS Crypto Tool is a Node.js package and command-line interface (CLI) utility for encrypting, decrypting, generate encryption key, and authenticating DLMS APDU messages.
- 🔒 Encryption: Encrypts DLMS APDU messages.
- 🔑 Decryption: Decrypts APDU messages.
- 🧾 Authentication: Generates authentication tags.
-
💻 CLI Interface: Interact with the tool via a command‑line utility (
dlmscli
). - 📁 File I/O Support: Optionally load input data from files and output results to files.
- 📝 Verbose Mode: Provides detailed logging for debugging and traceability.
- ✅ Well-Tested: Unit tests are provided with Mocha to ensure core functionality.
- Node.js vs23.11.0 (tested only with this version)
- Commander
- Mocha if you want run Unit tests
- npm (comes with Node.js)
You can install the package globally from npm to get the CLI:
npm install -g dlms_crypto_tool
Or install it as a dependecy in your project:
npm install dlms_crypto_tool
The package provide a CLI command called dlmscli
.
🔑 Generate a Random Encryption Key
dlmscli key
🔐 Encrypt an APDU Message
System Title = 5249435249435249
Frame Counter = 80000001
Encryption Key = 454E4352595054494F4E4B45594B4559
Authentication Key = 41555448454E5449434154494F4E4B45
APDU = c001810001000060010aff0200
dlmscli encrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 c001810001000060010aff0200
Tip: Use --infile <path> to load input from a file and --outfile <path> to save the output
🔓 Decrypt an APDU Message
System Title = 5249435249435249
Frame Counter = 80000001
Encryption Key = 454E4352595054494F4E4B45594B4559
Authentication Key = 41555448454E5449434154494F4E4B45
APDU = 0de63f2331a09aa85e8830f5f3
dlmscli decrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3
Result
Encrypted/Decrypted APDU: c001810001000060010aff0200
🔎 Authenticate an APDU Message
System Title = 5249435249435249
Frame Counter = 00000001
Encryption Key = 454E4352595054494F4E4B45594B4559
Authentication Key = 41555448454E5449434154494F4E4B45
APDU = 0de63f2331a09aa85e8830f5f3
dlmscli auth 5249435249435249 00000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3
Result
TAG: 62d423292e0fe5320370881d
To run unit test using Mocha, follow these steps:
- Clone the repository and install the development dependencies:
git clone https://github.com/YourUsername/dlms-crypto-tool.git
cd dlms-crypto-tool
npm install
- Run tests:
npm test
Contributions are welcome! To contribute:
-
Fork the repository.
-
Create a new branch for your changes.
-
Write tests for your modifications.
-
Submit a pull request with a detailed explanation of your changes.
This project is licensed under the GNU General Public License v3.0