1. Signature
BasGate Document v2
  • BAS SDK Payment
    • Payment Flow
    • Payment Api backend
      • Introduction
      • Authentication
      • Initiate Transaction
      • Check Transaction Status
    • Frontend Bas Payment SDK
      • Flutter SDK
      • Android SDK
      • IOS SDK
    • Signature
      • Signature (Checksum) Documentation
    • Tools
      • Laravel Payment Gateway SDK
  1. Signature

Signature (Checksum) Documentation

Signature (Checksum) Generation Documentation#

This document outlines the technical mechanism for generating a secure signature (checksum) for API requests. This process ensures data integrity and authenticity by combining the request payload with a random salt, hashing the result, and encrypting the final string.

1. Core Logic Workflow#

The signature generation process consists of four main stages:

A. Input Preparation#

String Payload: If the input is a direct string (e.g., a JSON request body), it is used as is.
Dictionary/Array Payload: If the input is a key-value dictionary, the parameters are first sorted alphabetically by their keys (Ordinal sort). The values are then concatenated, separated by a pipe character |, with the trailing pipe removed.

B. Random Salt Generation & Concatenation#

A random string of exactly 4 characters is generated.
The characters are randomly picked from a specific predefined charset:
@#!abcdefghijklmonpqrstuvwxyz#@01234567890123456789#@ABCDEFGHIJKLMNOPQRSTUVWXYZ#@
The original input string is concatenated with a pipe | and the random string:
Format: input + "|" + randomString

C. Hashing (SHA-256)#

The concatenated string from the previous step is converted to a byte array using UTF-8 encoding.
It is hashed using the SHA-256 algorithm.
The resulting hash is converted to a lowercase Hexadecimal string (without any dashes).

D. Final Encryption (AES-CBC)#

The generated Hex hash is concatenated with the 4-character random string:
Format: hash + randomString
Encryption Key: The provided secret key is hashed using SHA-256 (with ASCII encoding) to produce a 256-bit key for AES.
Encryption Process: The concatenated string is encrypted using the AES (Rijndael) algorithm with the following parameters:
Mode: CBC (Cipher Block Chaining)
Padding: PKCS7
IV (Initialization Vector): A static 16-byte array: "@@@@&&&&####$$$$"
Finally, the encrypted byte array is converted into a Base64 string. This Base64 string is the final Signature.

2. Code Implementations#

Below are practical code examples in multiple languages to generate the signature.
C#
php
Python
java script
type script
Modified at 2026-05-19 15:45:01
Previous
IOS SDK
Next
Laravel Payment Gateway SDK
Built with