SMS & Whatsapp Gateway

Hash-Based Signature

A signature is a unique code used to ensure the security and authenticity of data during a transaction. The signature is created using cryptographic algorithms such as RSA and SHA-256. Each time a request is received, Espay will validate the signature to ensure that the transaction data originates from you and has not been altered during transmission.
Service Combination
Send SMS dan
Send WhatsApp
sender_id + rq_uuid + message_type + phone_number + signature_key

Signature Component

Component Description
sender_id
Sender ID from Espay team.
rq_uuid
Request identifier. A unique ID used to identify messages.
message_type
Message type.

Format:
  • Send SMS: SMS
  • Send WhatsApp: WA
phone_number
Destination phone number.
signature_key
Signature key from Espay team.

How to Create a Signature

Generating the Signature for Send SMS and Send WhatsApp follows the same steps, with the only difference being the value of message_type. Below are the complete steps:
  • sender_id       : SGOPLUS
  • rq_uuid         : smspr-test-011
  • message_type    : SMS
  • phone_number    : 6281218816222
  • signatureKey    : sgoplus201711aa
  1. Combine each signature component using a hash symbol (#) as a separator.
At the initial stage, combine sender_id, rq_uuid, message_type, and phone_number to form the base format. The signature_key will be added in the next step.
#sender_id#rq_uuid#message_type#phone_number#
Base format of the combined components:
#SGOPLUS#smspr-test-011#SMS#6281218816222#
  1. Convert the result from step 1 to uppercase (UPPERCASE).
Base format of the combined components:
#SGOPLUS#smspr-test-011#SMS#6281218816222#
Format of the combined components after converting to uppercase:
#SGOPLUS#SMSPR-TEST-011#SMS#6281218816222#
  1. Append the signature_key parameter to the uppercase format from step 2.
Format of the combined components after converting to uppercase:
#SGOPLUS#SMSPR-TEST-011#SMS#6281218816222#
Format of the combined components after uppercase + signature_key:
#SGOPLUS#SMSPR-TEST-011#SMS#6281218816222#sgoplus201711aa#
  1. Convert the combined format into a hash using the SHA-256 algorithm.
Format of the combined components after uppercase + signature_key:
#SGOPLUS#SMSPR-TEST-011#SMS#6281218816222#sgoplus201711aa#
Format of the combined components after applying SHA-256 hashing:
3ac657060474d31095e27eb49699098c81b317ca9d34e39489c9f77ba80ab758



Generate Signature for Send SMS

// Input parameters
$sender_id     = "SGOPLUS";
$rq_uuid       = "smspr-test-011";
$message_type  = "SMS";
$phone_number  = "6281218816222";
$signatureKey  = "sgoplus201711aa";

// 1. Combine all components using '#' as the separator
$combined = "#" . $sender_id . "#" . $rq_uuid . "#" . $message_type . "#" . $phone_number . "#";

// 2. Convert the entire string to uppercase
$combined_upper = strtoupper($combined);

// 3. Append the signatureKey at the end
$combined_with_key = $combined_upper . $signatureKey . "#";

// 4. Generate the SHA-256 hash
$signature = hash('sha256', $combined_with_key);

// Output signature
echo "Initial format:\n " . $combined;
echo "\n\nFormat after converting to uppercase:\n " . $combined_upper;
echo "\n\nFormat after appending Signature Key:\n " . $combined_with_key;
echo "\n\nFinal Signature (SHA-256 hash):\n " . $signature;
                
            

Generate Signature for Send Whatsapp

// Input parameters
$sender_id     = "SGOPLUS";
$rq_uuid       = "wapr-test-011";
$message_type  = "WA";
$phone_number  = "6281218816222";
$signatureKey  = "sgoplus201711aa";

// 1. Combine all components using '#' as the separator
$combined = "#" . $sender_id . "#" . $rq_uuid . "#" . $message_type . "#" . $phone_number . "#";

// 2. Convert the entire string to uppercase
$combined_upper = strtoupper($combined);

// 3. Append the signatureKey at the end
$combined_with_key = $combined_upper . $signatureKey . "#";

// 4. Generate the SHA-256 hash
$signature = hash('sha256', $combined_with_key);

// Output signature
echo "Initial format:\n " . $combined;
echo "\n\nFormat after converting to uppercase:\n " . $combined_upper;
echo "\n\nFormat after appending Signature Key:\n " . $combined_with_key;
echo "\n\nFinal Signature (SHA-256 hash):\n " . $signature;
                
              



Generate Signature for Send SMS

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SmsSignatureGenerator {

    public static void main(String[] args) {
        // Input parameters
        String senderId     = "SGOPLUS";
        String rqUuid       = "smspr-test-011";
        String messageType  = "SMS";
        String phoneNumber  = "6281218816222";
        String signatureKey = "sgoplus201711aa";

        // 1. Combine all components using '#' as the separator
        String combined = "#" + senderId + "#" + rqUuid + "#" + messageType + "#" + phoneNumber + "#";

        // 2. Convert the entire string to uppercase
        String combinedUpper = combined.toUpperCase();

        // 3. Append the signatureKey at the end
        String combinedWithKey = combinedUpper + signatureKey + "#";

        // 4. Generate the SHA-256 hash
        String signature = sha256(combinedWithKey);

        // Output
        System.out.println("Initial format:\n" + combined);
        System.out.println("\nFormat after converting to uppercase:\n" + combinedUpper);
        System.out.println("\nFormat after appending Signature Key:\n" + combinedWithKey);
        System.out.println("\nFinal Signature (SHA-256 hash):\n" + signature);
    }

    // Method untuk hashing SHA-256
    public static String sha256(String base) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(base.getBytes(StandardCharsets.UTF_8));
            StringBuilder hexString = new StringBuilder();

            for (byte b : hash) {
                String hex = Integer.toHexString(0xff & b);
                if(hex.length() == 1) hexString.append('0');
                hexString.append(hex);
            }

            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("SHA-256 algorithm not found.");
        }
    }
}
                
            

Generate Signature for Send Whatsapp

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SmsSignatureGenerator {

    public static void main(String[] args) {
        // Input parameters
        String senderId     = "SGOPLUS";
        String rqUuid       = "wapr-test-011";
        String messageType  = "WA";
        String phoneNumber  = "6281218816222";
        String signatureKey = "sgoplus201711aa";

        // 1. Combine all components using '#' as the separator
        String combined = "#" + senderId + "#" + rqUuid + "#" + messageType + "#" + phoneNumber + "#";

        // 2. Convert the entire string to uppercase
        String combinedUpper = combined.toUpperCase();

        // 3. Append the signatureKey at the end
        String combinedWithKey = combinedUpper + signatureKey + "#";

        // 4. Generate the SHA-256 hash
        String signature = sha256(combinedWithKey);

        // Output
        System.out.println("Initial format:\n" + combined);
        System.out.println("\nFormat after converting to uppercase:\n" + combinedUpper);
        System.out.println("\nFormat after appending Signature Key:\n" + combinedWithKey);
        System.out.println("\nFinal Signature (SHA-256 hash):\n" + signature);
    }

    // Method untuk hashing SHA-256
    public static String sha256(String base) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(base.getBytes(StandardCharsets.UTF_8));
            StringBuilder hexString = new StringBuilder();

            for (byte b : hash) {
                String hex = Integer.toHexString(0xff & b);
                if(hex.length() == 1) hexString.append('0');
                hexString.append(hex);
            }

            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("SHA-256 algorithm not found.");
        }
    }
}
                
            



Generate Signature for Send SMS

const crypto = require('crypto');

// Input parameters
const sender_id     = "SGOPLUS";
const rq_uuid       = "smspr-test-011";
const message_type  = "SMS";
const phone_number  = "6281218816222";
const signatureKey  = "sgoplus201711aa";

// 1. Combine all components using '#' as the separator
let combined = `#${sender_id}#${rq_uuid}#${message_type}#${phone_number}#`;
console.log("Initial format:\n", combined);

// 2. Convert the entire string to uppercase
let combined_upper = combined.toUpperCase();
console.log("\nFormat after converting to uppercase:\n", combined_upper);

// 3. Append the signatureKey at the end
let combined_with_key = combined_upper + signatureKey + "#";
console.log("\nFormat after appending Signature Key:\n", combined_with_key);

// 4. Generate the SHA-256 hash
let signature = crypto.createHash('sha256').update(combined_with_key).digest('hex');
console.log("\nFinal Signature (SHA-256 hash):\n", signature);
                
            

Generate Signature for Send Whatsapp

const crypto = require('crypto');

// Input parameters
const sender_id     = "SGOPLUS";
const rq_uuid       = "wapr-test-011";
const message_type  = "WA";
const phone_number  = "6281218816222";
const signatureKey  = "sgoplus201711aa";

// 1. Combine all components using '#' as the separator
let combined = `#${sender_id}#${rq_uuid}#${message_type}#${phone_number}#`;
console.log("Initial format:\n", combined);

// 2. Convert the entire string to uppercase
let combined_upper = combined.toUpperCase();
console.log("\nFormat after converting to uppercase:\n", combined_upper);

// 3. Append the signatureKey at the end
let combined_with_key = combined_upper + signatureKey + "#";
console.log("\nFormat after appending Signature Key:\n", combined_with_key);

// 4. Generate the SHA-256 hash
let signature = crypto.createHash('sha256').update(combined_with_key).digest('hex');
console.log("\nFinal Signature (SHA-256 hash):\n", signature);
                
            
Scroll to Top