AirtelMoney.Encryption (airtel_money v0.1.0)

Copy Markdown View Source

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

encrypt_pin(pin, public_key \\ nil)

@spec encrypt_pin(String.t(), String.t() | nil) ::
  {:ok, String.t()} | {:error, String.t()}

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"}

fetch_public_key()

@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