![JAR search and dependency download from the Maven repository](/logo.png)
com.binance.connector.client.utils.SignatureGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binance-connector-java Show documentation
Show all versions of binance-connector-java Show documentation
lightweight connector to API
package com.binance.connector.client.utils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Hex;
public class SignatureGenerator {
private static final String HMAC_SHA256 = "HmacSHA256";
private SignatureGenerator() {
}
public static final String getSignature(String data, String key) {
byte[] hmacSha256;
try {
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), HMAC_SHA256);
Mac mac = Mac.getInstance(HMAC_SHA256);
mac.init(secretKeySpec);
hmacSha256 = mac.doFinal(data.getBytes());
} catch (Exception e) {
throw new RuntimeException("Failed to calculate hmac-sha256", e);
}
return Hex.encodeHexString(hmacSha256);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy