Skip to content

Instantly share code, notes, and snippets.

@X1ting
Created February 26, 2023 23:49
Show Gist options
  • Select an option

  • Save X1ting/6d814e5f9dd0cbc47f8eaed5f2ee65e0 to your computer and use it in GitHub Desktop.

Select an option

Save X1ting/6d814e5f9dd0cbc47f8eaed5f2ee65e0 to your computer and use it in GitHub Desktop.
Check telegram auth token
data = {
auth_date: DATE,
first_name: "NAME",
hash: "HASH",
id: ID,
last_name: "SURNAME",
photo_url: "PHOTO",
username: "USERNAME"
}
token = "YOUR_TOKEN"
check_data = data.except(:hash).sort.to_h.map { |k,v| "#{k}=#{v}"}.join("\n")
hashed_token = Digest::SHA256.digest(token)
hash = OpenSSL::HMAC.hexdigest("SHA256", hashed_token, check_data)
puts data[:hash] == hash
@useeerfotopaketbot
Copy link

Screenshot_20240107_225124
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment