IRI.Maptor.Core.Security
Cryptography and security primitives used across the Maptor ecosystem — AES encryption, RSA public-key encryption and key management, hashing, and HMAC-signed JSON Web Tokens. All types live in the IRI.Maptor.Core.Security namespace.
Installation
dotnet add package IRI.Maptor.Core.Security
Features
- AES/Rijndael symmetric encryption:
RijndaelHelper.AesEncrypt/AesDecryptwith explicit key/IV, plus password-basedEncrypt/Decrypt - RSA public-key cryptography:
CryptoRSAHelperwithRsaEncrypt/RsaDecrypt, key-pair generation in XML (GenerateKeysInXml) and PEM (GenerateKeysInPem), and key-format conversion helpers RSACryptoServiceProviderExtension— load public/private keys from DER blobs and PEM strings- Key containers:
RsaKeys(XML key pair) andRsaMessage/EncryptedMessageenvelopes - Hashing:
HashAlgorithmHelperwith MD5 and SHA-256 helpers (with optional salt) plus a genericCalculateHash(input, HashAlgorithm)for any algorithm - JWT:
SignedJsonWebToken— create (viaToString()) and validate (viaParse) HMAC-SHA256 signed tokens with claims, issuer, audience, and expiry checks CryptographyHelper— Base64/Base64URL utilities and random data generation- Google OAuth service helper (
GoogleOAuthService)
Usage
Hashing:
using IRI.Maptor.Core.Security;
string sha256 = HashAlgorithmHelper.CalculateSha256Hash("my-password");
string salted = HashAlgorithmHelper.GetMd5Hash("my-password", "my-salt");
RSA round trip:
using IRI.Maptor.Core.Security;
var keys = CryptoRSAHelper.GenerateKeysInXml(keySize: 2048);
string cipher = CryptoRSAHelper.RsaEncrypt("secret message", keys.PublicKeyAsBase64Xml);
string plain = CryptoRSAHelper.RsaDecrypt(cipher, keys.PrivateKeyAsBase64Xml);
AES with explicit key and IV:
using IRI.Maptor.Core.Security;
string encrypted = RijndaelHelper.AesEncrypt("sensitive data", key, iv);
string decrypted = RijndaelHelper.AesDecrypt(encrypted, key, iv);
Limitations
- RSA signing/verification helpers are not implemented — the RSA helpers cover encryption, decryption, and key management only.
SignedJsonWebTokensupports the HMAC-SHA256 (HS256) algorithm only.