Encryption module for Airtel Money PIN encryption.
Uses RSA public key encryption with OAEP padding for PIN protection as required by Airtel Money API.
Summary
Functions
Encrypts a PIN using RSA encryption with OAEP padding and Airtel's public key.
Fetches Airtel's RSA public key from the API.
Functions
Encrypts a PIN using RSA encryption with OAEP padding and Airtel's public key.
Parameters
pin- The PIN to encrypt (string)public_key- Airtel's RSA public key in Base64 DER format (optional, will use config if not provided)
Returns
{:ok, encrypted_pin} on success, {:error, reason} on failure
Examples
iex> AirtelMoney.Encryption.encrypt_pin("1234")
{:ok, "encrypted_base64_string"}
@spec fetch_public_key() :: {:ok, String.t()} | {:error, AirtelMoney.Error.t()}
Fetches Airtel's RSA public key from the API.
Returns
{:ok, public_key} on success, {:error, reason} on failure