# Web API access with SHA-512 authentication



## tacticaltrading (Dec 14, 2013)

My goal is to access Cryptsy.com and pull lots of data into excel....

I have the simple public API working, (Thank you: jSon - Excel Liberation   and excelent resource) 
However, I am unable to perform and authenticate a secure http Post. 

I need to perform the following PHP code using VBA

// generate the POST data string 
       $post_data = http_build_query($req, '', '&'); 
       $sign = hash_hmac("sha512", $post_data, $secret);

Building $post_data is accomplished with a simple loop. 
I need help generating the 

$sign = hash_hmac("sha512", post_data, Key)  
'/sha512 is the encryption, post_data is what is to be encryped, and key is the secret

Does anyone know how to make this happen in VBA? 




the following is from https://www.cryptsy.com/pages/api
Authenticated Methods
Authenticated methods require the use of an api key and can only be accessed via the POST method. 
*URL - The URL you will be posting to is: https://www.cryptsy.com/api (notice it does NOT have the '.php' at the end) 
Authorization is performed by sending the following variables into the request header: 
Key — Public API key. An example API key: 5a8808b25e3f59d8818d3fbc0ce993fbb82dcf90 
Sign — ALL POST data (param=val&param1=val1) signed by a secret key according to HMAC-SHA512 method. Your secret key and public keys can be generated from your account settings page. 
An additional security element must be passed into the post: 
nonce - All requests must also include a special nonce POST parameter with incrementing integer. The integer must always be greater than the previous requests nonce value. 


Other Variables 
method - The method from the list below which you are accessing. 
General Return Values 
success - Either a 1 or a 0. 1 Represents sucessful call, 0 Represents unsuccessful 
error - If unsuccessful, this will be the error message 
return - If successful, this will be the data returned 
Method List 
Method: getinfo 
Inputs: n/a 
Outputs:  .....:=  JSON formated object (which is another story)


Thanks in advance for any help or guidance

*


----------



## BRUCEMCPHERSON (Dec 16, 2013)

Haven't tried with sha512, but here's how to use System.Security.Cryptography.HMACSHA1 in VBA. HMACSHA512 should be similar.

 Encoding client keys for Maps - Excel Liberation

Bruce





tacticaltrading said:


> My goal is to access Cryptsy.com and pull lots of data into excel....
> 
> I have the simple public API working, (Thank you: jSon - Excel Liberation   and excelent resource)
> However, I am unable to perform and authenticate a secure http Post.
> ...


----------

