In today’s post, let’s explore one of the most interesting and often overlooked areas of Microsoft Dynamics 365 Business Central — the Cryptography Management (Codeunit 1266).
This codeunit empowers developers to perform hashing and encryption operations directly within AL code, enabling scenarios such as secure data storage, integrity validation, and password handling — all without relying on external libraries or custom .NET integrations.
The Cryptography Management codeunit provides multiple procedures for managing hashing and symmetric encryption.
👉 In this post, we’ll focus on the GenerateHash procedure, which allows you to create hash values using popular algorithms like MD5, SHA1, SHA256, SHA384, and SHA512.
Understanding the GenerateHash Procedure
Purpose:
The GenerateHash function creates a unique hash value from any text you provide.
You can choose from several hashing algorithms such as MD5, SHA1, SHA256, SHA384, and SHA512.
Parameters:
- InputString: The text or value you want to convert into a hash.
- HashAlgorithmType: The algorithm you want to use (MD5, SHA1, SHA256, SHA384, or SHA512).
Returns:
A hexadecimal string that represents the hashed value of your input.
What is Hashing?
Hashing is a one-way process that changes your input text into a fixed-length string of characters.
Once hashed, the original text cannot be reversed or recovered — making it useful for secure storage and validation.
Example of Hash Algorithms
| Algorithm | Hash Length | Description |
|---|---|---|
| MD5 | 128 bits | Fast but outdated |
| SHA1 | 160 bits | Older, less secure |
| SHA256 | 256 bits | Common and secure choice |
| SHA384 | 384 bits | Stronger security level |
| SHA512 | 512 bits | Very strong and longest output |
Below is a practical example page that uses the Cryptography Management
codeunit to generate hashes for different algorithms.
Output:
With just a few lines of AL code, you can securely hash and validate any piece of text.
The built-in Cryptography Management codeunit makes it seamless for Business Central developers to implement modern cryptographic functions without needing external libraries.
Stay tuned — in the next post, we’ll explore Cryptography in Business Central and learn how to safely encrypt and decrypt data strings 🔐✨
Thanks For Reading...!!
Regards,
Khushbu Rajvi

Like
Report
*This post is locked for comments