Requires: OpenSSL (auto-installed via minks install crypto)
#include "crypto"
AES-256-CBC encryption, SHA-512 hashing, HMAC-SHA256, PBKDF2 key derivation, and cryptographically secure random bytes.
| Method | Args | Out | Description |
|---|---|---|---|
Crypto:AESEncrypt |
keyHex, ivHex, plaintext |
String | AES-256-CBC encrypt → base64 ciphertext. keyHex = 64 hex chars (32 bytes), ivHex = 32 hex chars (16 bytes) |
Crypto:AESDecrypt |
keyHex, ivHex, cipherBase64 |
String | AES-256-CBC decrypt → plaintext |
Crypto:SHA512 |
input |
String | SHA-512 hash → 128-char hex string |
Crypto:HMAC256 |
keyHex, message |
String | HMAC-SHA256 → 64-char hex string |
Crypto:PBKDF2 |
password, saltHex, iterations, keyLen |
String | PBKDF2-SHA256 key derivation → hex string of keyLen bytes |
Crypto:Random |
byteCount |
String | Cryptographically secure random bytes → hex string |
Throws CryptoException on failure. See Object — Exception.
Var:String key;
Var:String iv;
Var:String cipher;
Var:String plain;
Var:String hash;
// Generate a random 32-byte key and 16-byte IV
Crypto:Random(32, key);
Crypto:Random(16, iv);
Crypto:AESEncrypt(key, iv, "Hello, World!", cipher);
Crypto:AESDecrypt(key, iv, cipher, plain);
Konsol:Print(plain); // Hello, World!
Crypto:SHA512("my password", hash);
Konsol:Print(hash); // 128-char hex
On MSYS2, OpenSSL is typically already present as a dependency of curl — check with pkg-config --exists openssl && echo found before installing.
| Platform | Command |
|---|---|
| Debian/Ubuntu | sudo apt install libssl-dev |
| Fedora/RHEL | sudo dnf install openssl-devel |
| macOS | brew install openssl |
| MSYS2 MINGW64 | pacman -S mingw-w64-x86_64-openssl |
| MSYS2 UCRT64 | pacman -S mingw-w64-ucrt-x86_64-openssl |
| MSYS2 CLANG64 | pacman -S mingw-w64-clang-x86_64-openssl |
| MSYS2 CLANGARM64 | pacman -S mingw-w64-clang-aarch64-openssl |
The Makefile auto-detects via pkg-config. For native Windows, download Win64 OpenSSL and override OPENSSL_DIR if not using the default (C:/OpenSSL-Win64):
make -C crypto_plugin OPENSSL_DIR="C:/your/openssl"