Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuiler/d9b8737528cc8805b739d7bf04c0af01 to your computer and use it in GitHub Desktop.
Save wuiler/d9b8737528cc8805b739d7bf04c0af01 to your computer and use it in GitHub Desktop.
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.HmacUtils;
private Boolean isTelegramAccountDataRight(
String telegramAccountData, // data check string
String telegramBotToken // bot token
) {
byte[] data = telegramAccountData.toString().getBytes();
byte[] secret = DigestUtils.sha256(telegramBotToken);
String hashParam = telegramAccount.getHash();
String hash = HmacUtils.hmacSha256Hex(secret, data);
return hash.equals(hashParam);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment