Signature
To ensure secure communication with the Rumbapay API, all requests must include a signature in the headers. Similarly, all responses from the Rumbapay API will contain a signature header as well. This signature verifies the authenticity of both requests and responses, ensuring the integrity of the payload in both directions.
Signature Formula:
signature = HMACSHA256(Password, Login + JSON)Where:
Login: Your merchant login
JSON: The complete JSON request/response body as a string
Password: Your merchant password (used as the secret key for HMAC)
Header Example:
signature: eec909f2e9575792e659dda29cc6e78c85e7de69f1281124e21afeca5bf5c477Note: The signature must be included in the headers of every API request, and Rumbapay will always include a signature header in all responses. Validating this signature in responses is essential to ensure the response hasn't been tampered with during transmission.
Security Note: HMACSHA256 provides improved security over standard SHA256 by using a secret key (your password) in the hashing process, which helps protect against certain types of cryptographic attacks.
Signature Implementation Examples
1. Node.js Example
const crypto = require('crypto');
function generateSignature(login, jsonData, password) {
// Convert JSON to string if it's an object
const jsonString = typeof jsonData === 'object' ? JSON.stringify(jsonData) : jsonData;
// Concatenate login + JSON
const dataToSign = login + jsonString;
// Generate HMACSHA256 hash using password as the key
return crypto.createHmac('sha256', password).update(dataToSign).digest('hex');
}
// Example usage
const login = 'john_yablonliy';
const password = '4f56cc8f-eb99-4b5d-9255-52ae6f23e91c';
const jsonData = { /* Your JSON data */ };
const signature = generateSignature(login, jsonData, password);
console.log('Signature:', signature);
// Add signature to request headers
const headers = {
'Content-Type': 'application/json',
'signature': signature
};2. C# Example
3. Java Example
Security Best Practices
Always use HTTPS for all API communications.
Keep your login and password secure; never expose them in client-side code.
Validate both request and response signatures to ensure data integrity.
Use proper error handling for failed signature validations.
Implement request timeouts to prevent replay attacks.
Using HMACSHA256 over standard SHA256 provides better security as it includes a secret key in the hashing process.
Validating Responses
To validate API responses, follow a similar process:
Extract the
signaturefrom the response headers.Generate a signature using the HMACSHA256 algorithm with your password as the key and login + response body as the message.
Compare the generated signature with the received signature.
If they match, the response is authentic and hasn't been tampered with.
Last updated