Thanks for the code, it really is nice of you to write it. I am new to encryption, but from the php output of $sign it looks like I need to convert the returned array of bytes to a string of hexadecimals before submitting it to cryptsy? After a lot of studying your code, it appears your subroutine returns an array of 64 bytes, each value ranging from -128 to 127.
Using your code, the Encryption library and the ByteConverter library, this is what I have so far:
Sub Process_Globals
End Sub
Sub Globals
Dim API_Key, API_Secret, Post_Data As String
Dim Byte_Conv As ByteConverter
Dim stringdata As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
API_Secret = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
Post_Data = "method=getinfo&nonce=1"
Dim Sign() As Byte = HashHmac(Post_Data, API_Secret)
Dim Sign_String As String
Sign_String = Byte_Conv.StringFromBytes(Sign, "UTF8")
Log("Sign_String = " & Sign_String)
End Sub
Sub HashHmac(data As String, secret As String) As Byte()
Dim m As Mac 'm As Message Authentication Code
Dim kg As KeyGenerator
kg.Initialize("HmacSHA512") 'initialize kg using HmacSHA512 algorithm
kg.KeyFromBytes(secret.GetBytes("UTF8")) 'encode string "secret" to an array of Bytes using UTF8
m.Initialise("HmacSHA512", kg.Key) 'initialize m using HmacSHA512 algorithm and the secret key
m.Update(data.GetBytes("UTF8")) 'encodes post data to an array of Bytes and loads it to be signed
Return m.Sign 'sign the loaded data using the secret key, return the calc signature data
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Log Output:
Sign_String = �D�l�@�ת'���t����Ο�eRh��W�X�z��\��5�8�EI{�3�=,�fy
Using the real API_Secret gets me similar results.
The array of bytes from "Sign()" vary from -128 to 127. When converting to a string, the positive bytes get characters and the negative bytes get diamonds. From my experimenting with UTF8 it looks like the numbers "0,1,2,3,4,5,6,7,8,9" are from byte values 48 to 57 and letters "a,b,c,d,e,f" are from byte values 65 to 71. Does this mean my output array of bytes "Sign()" needs to be in those ranges to get a real hexadecimal output?
Am I on the right track by trying to convert to a string, or did I fly way off the rails?