using System.Security.Cryptography;
string privateKey = "au6RRBKcqrmSnh9RN8KNEBaKBEEEDcwwKbChTWb7FPxsZMtsUzuvQWGXCj8V87QnpBWYrHtVfKK6csfAKJaxW7w58NdZ2jXMBnNrsRfdJnWhXzLXU52Lddc8Sfss35kn";
string publicKey = "4LDVS4Kv5S5sxT83FNHp5LzDcKb9wnkE";
string urlAuthorize = "https://preprod.api.catalizr.io/authorize/";
string urlGetInvestor = "https://preprod.api.catalizr.io/papi/investors/email/sophie.willmann@creditmutuel.fr";
string nonceAuthorize = GetNonce();
string signatureAuthorize = GetSignatureAuthorize(privateKey, publicKey, nonceAuthorize, urlAuthorize);
string nonceGetInvestor = GetNonce();
string signatureGetInvestor = GetSignatureGetInvestor(privateKey, publicKey, nonceGetInvestor, urlGetInvestor);
Console.WriteLine("Public key : " + publicKey);
Console.WriteLine("Signature authorize : " + signatureAuthorize);
Console.WriteLine("Nonce authorize : " + nonceAuthorize);
Console.WriteLine("Signature getInvestor : " + signatureAuthorize);
Console.WriteLine("Nonce getInvestor : " + nonceGetInvestor);
private string GetNonce()
var ts = DateTime.UtcNow - new DateTime(1970,1,1);
return ts.TotalMilliseconds.ToString().Substring(0, 13);
private string GetSignatureAuthorize(string privateKey, string publicKey, string nonce, string url)
HMACSHA512 hmac = new HMACSHA512(Encoding.ASCII.GetBytes(privateKey));
byte[] computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(nonce + url + "{\"apiPublicKey\": \"" + publicKey + "\"}"));
return BitConverter.ToString(computedHash).Replace("-", string.Empty).ToLower();
private string GetSignatureGetInvestor(string privateKey, string publicKey, string nonce, string url)
HMACSHA512 hmac = new HMACSHA512(Encoding.ASCII.GetBytes(privateKey));
byte[] computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(nonce + url));
return BitConverter.ToString(computedHash).Replace("-", string.Empty).ToLower();