Signature
Security Scheme Type | API Key |
---|---|
Header parameter name: | API-Signature |
Header example
{
"API-Signature": "bdGlTv9Q3A6x2x4Ruflzkwlnxv5cizYS3+rcL9/4nKQ/18HTugRGMPDUOo6+aofO8x6C7QDMZdo/KTz7leKHjA",
"Content-Type": "application/json"
}
The signature used to verify your request.
To check the callback signature in the header, you have to create your own according to this scheme.
The following parameters are required to create a signature:
secret
-- provided to you by our servicecontent
-- the body of the request, converted to a string When all the parameters are ready, you need to use the cryptographic hashing for those parameters, as shown below:signature = hmac_sha512_base64( sha256(content), secret )
You have to add the prepared signature to the header of the request Switchere Callbacks to your system.
The callbacks will be sent to the URL you provide viaPOST
.
Examples
perl
my $secret = 'xxxxxxxx'; # provided by our service
my $content = '{"partner_order_id":"xxxxx-xxxxx-xxxx1"}';
my $signature = hmac_sha512_base64( sha256($content), $secret );
php
$secret = 'xxxxxxxx'; # provided by our service
$content = '{"partner_order_id":"xxxxx-xxxxx-xxxx1"}';
$signature = base64_encode(hash_hmac('sha512', hash('sha256', $content, true), $secret, true));
python
import hashlib
import hmac
import base64
m = hashlib.sha256()
m.update(b'{"payin_group": "crypto","payin_amount": 1,"payin_currency": "ETH","payout_group": "crypto","payout_currency": "BTC","payout_group": "balance"}')
tmp = m.digest()
sign = hmac.new(b'xS!R1yRxZp8MoOJKC2?FsC8f2u027qAA', tmp, hashlib.sha512).hexdigest()
print(base64.b64encode(hmac.new(b"xS!R1yRxZp8MoOJKC2?FsC8f2u027qAA", msg=tmp, digestmod=hashlib.sha512).digest()))
java
import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Mac;
import javax.xml.bind.DatatypeConverter;
public class Sign {
public static void main(String args[]) {
try {
String content ='{"payin_group": "crypto","payin_amount": 1,"payin_currency": "ETH","payout_group": "crypto","payout_currency": "BTC","payout_group": "balance"}';
String secret = "xU4OfNlpcf0NMmlASDSMLGZB7cIaYhCWl";
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(
content.getBytes(StandardCharsets.UTF_8));
SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes(), "HmacSHA512");
Mac mac = Mac.getInstance("HmacSHA512");
mac.init(secretKeySpec);
String sign = DatatypeConverter.printBase64Binary( mac.doFinal(hash));
System.out.println(sign);
} catch (Exception e) {}
}
}