Link to home
Start Free TrialLog in
Avatar of bill smily
bill smily

asked on

VB6 sha512 sign from secret key and return URL -Any Solution

Hello

Required is any code and or Dll or any solution to digitally sign a url with a secret api-key and Post it back to the server that can work in VB6

This is an Example in PHP  , need some type of hash_hmac equivalence in VB6 and example if possible.

$apikey='xxx';
$apisecret='xxx'; 
$nonce=time(); 
$uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce; 
$sign=hash_hmac('sha512',$uri,$apisecret); 
$ch = curl_init($uri); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign)); 
$execResult = curl_exec($ch); 
$obj = json_decode($execResult);

Open in new window


For a more exact definition , I have a another question posted here that is kinda different since its is as far as I am on my own  
trying to solve this, but i think this is worthy as separate question .
Please I really need something that will work in vb6.

Thank You Experts
SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am sorry Bill. I posted VB.Net code not VB6 code. One question though, any specific reason to use VB6?
Avatar of bill smily
bill smily

ASKER

An old Classic Visual Basic, VB6  project is required asap is being brought back into service, its the only part that needs a fix.

Old Timer Needs Help
(Decades ago we could post points,Im not sure how it works now, I am back from 20 years ago, how do I add incentive for experts .)
I don't think this qualifies as a valid answer and you should not allocate any points to my answer. Now if you are asking in general, I think help section is ur best bet. I am sorry but I never used ask question feature so don't have the answer.
(Decades ago we could post points,Im not sure how it works now, I am back from 20 years ago, how do I add incentive for experts .)
That IS old! EE hasn't allowed adding points in a looooooong time. I'm sure Chinmay can help ...
I think I found a w0rking example here
'https://fujori.com/wp-content/uploads/2018/02/bittrex_connect.txt

i think if.net framework installed it will work ok
I am testing this tonight

Public Function hashHmacSHA512(uri As String, apikey As String)
   
    Dim keyArray(64) As Byte
    Dim i As Long
    Dim text As Object
    Dim SHA512 As Object
    Dim xml As Object
   
    On Error GoTo erre5423:
   
    For i = 0 To 63
        keyArray(i) = Asc(Mid(apikey, i + 1, 1))
    Next
    On Error GoTo 0
   
    Set text = CreateObject("System.Text.UTF8Encoding")
    Set SHA512 = CreateObject("System.Security.Cryptography.HMACSHA512")
    Set xml = CreateObject("MSXML2.DOMDocument")
   
    SHA512.key = keyArray()
    xml.loadXML "<root />"
    xml.DocumentElement.DataType = "bin.Hex"
    xml.DocumentElement.nodeTypedValue = SHA512.ComputeHash_2((text.GetBytes_4(uri)))
    hashHmacSHA512 = Replace(xml.DocumentElement.text, vbLf, "")
Exit Function
erre5423:
MsgBox "err hashHmacSHA512 " & Err.Description
End Function
Hi Bill,

I found the link after I logged on to my computer - the earlier post was from my cell where it was hard to locate.

http://support.experts-exchange.com/customer/en/portal/articles/2527982-how-do-i-close-my-question-?b_id=44

In this case, your answer - if it works - will qualify as the answer. Please close the question accordingly.

Regards,
Chinmay.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if key is 32 long change 63 to 31
Chinmay tipped me on Security.Cryptography and from that I was able to

find a good vb example I posted above
Thank you bill :)