telegram-login-rs

A rust implementation of the verification of Telegram Login requests.

Based on the example from the Telegram docs.

Examples:

```rs extern crate chrono; extern crate telegram_login;

use chrono::NaiveDateTime; use telegramlogin::{TelegramLogin, TelegramLoginError, checksignature};

let tl = TelegramLogin { id: 666666666, username: Some("myusername".tostring()), firstname: Some("Some".tostring()), lastname: Some("Guy".tostring()), photourl: Some("https://t.me/i/userpic/320/myusername.jpg".tostring()), authdate: NaiveDateTime::fromtimestamp(1543194375, 0), hash: "a9cf12636fb07b54b4c95673d017a72364472c41a760b6850bcd5405da769f80".to_string() };

let bottoken = "777777777:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".tostring();

match checksignature(bottoken, t_l) { Ok(()) => { // The login is valid, so we can log the user in. } Err(TelegramLoginError::InvalidHash) => { // The login failed, so we need to return an error to the client. } Err(TelegramLoginError::VerificationFailed) => { // The login failed, so we need to return an error to the client. } } ```