using System.Security.Cryptography;
public static void Main()
Console.WriteLine(getAuthentication("post", "api-hcm", "12345678@a"));
public static String getAuthentication(String method, String User, String Password)
String value = String.Format("{0}:{1}:{2}", User, Password, Guid.NewGuid().ToString("N").ToLower());
var nonce = Guid.NewGuid().ToString("N").ToLower();
DateTime epochStart = new DateTime(1970, 01, 01, 0, 0, 0, 0, DateTimeKind.Utc);
TimeSpan currentTimes = DateTime.UtcNow - epochStart;
var serverTotalSeconds = Convert.ToInt32(currentTimes.TotalSeconds);
string data = String.Format("{0}{1}{2}", method, serverTotalSeconds, nonce);
value = String.Format("{0}:{1}:{2}:{3}:{4}", getHashedData(data), nonce, serverTotalSeconds, User, Password);
static string getHashedData(string data)
var hash = md5.ComputeHash(Encoding.Default.GetBytes(data));
return Convert.ToBase64String(hash);