using System.Security.Cryptography;
public static void Main()
Console.WriteLine(GetLoginUrl());
public static string GetLoginUrl()
const string key = "0e896dfe28b327ffc7977bc511ce76f0";
const string pathTemplate = "http://shreyasns.freshdesk.com/login/sso?name={0}&email={1}×tamp={2}&hash={3}";
var username = "Shreyas";
var email = "shreyas.ns@freshdesk.com";
int time = (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
string timems = time.ToString();
var hash = GetHash(key, username, email, timems);
var path = String.Format(pathTemplate, HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(email), timems, hash);
private static string GetHash(string secret, string name, string email, string timems)
string input = name + email + timems;
var keybytes = Encoding.Default.GetBytes(secret);
var inputBytes = Encoding.Default.GetBytes(input);
var crypto = new HMACMD5(keybytes);
byte[] hash = crypto.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
string hexValue = b.ToString("X").ToLower();
sb.Append((hexValue.Length == 1 ? "0" : "") + hexValue);