I think you have gotten helpful pointers in the responses so far. The result needs to come back as *c and the cd paramter for that should be a char list of the right length.
Let me know if your troubles persist as I have working code for SHA1 that I can post. On Fri, Sep 6, 2013 at 12:10 AM, Pascal Jasmin <[email protected]> wrote: > I'm trying to get sha256 from microsoft's library working. > > MS documentation on the last call in my function: > http://msdn.microsoft.com/en-us/library/windows/desktop/aa379947(v=vs.85).aspx > > The problem is that the 3rd param to CryptGetHashParam is a pointer to a byte > array, and should hold the hash result, but I'm unable to see it change. The > 2nd param in CryptHashData may also be called incorrectly here. > > any help? > > > ALG_SID_SHA_256 =: 12 > ALG_CLASS_HASH =: 32768 > PROV_RSA_FULL =:1 > PROV_RSA_AES =: 24 > HP_HASHVAL =: 2 > CRYPT_VERIFYCONTEXT =: 4026531840 > CryptAcquireContext =: ('advapi32.dll CryptAcquireContextA i *i c c i i') & cd > NB.(ByRef phProv As Long, ByVal pszContainer As String, ByVal pszProvider As > String, ByVal dwProvType As Long, ByVal dwFlags As Long) > CryptReleaseContext =: 'advapi32.dll CryptReleaseContext i i i' & cd > NB. (ByVal hProv As Long, ByVal dwFlags As Long) As Long > CryptCreateHash =: 'advapi32.dll CryptCreateHash i *i i i i *i' & cd > NB.(ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal > dwFlags As Long, ByRef phHash As Long) As Long > CryptDestroyHash =: 'advapi32.dll CryptDestroyHash i i' & cd > NB.(ByVal hHash As Long) As Long > CryptHashData =: 'advapi32.dll CryptHashData i *i *c i i' & cd > NB.(ByVal hHash As Long, pbData As Any, ByVal cbData As Long, ByVal dwFlags > As Long) As Long > CryptGetHashParam =: 'advapi32.dll CryptGetHashParam i *i i *c *i i' & cd > NB.(ByVal hHash As Long, ByVal dwParam As Long, pbData As Any, ByRef pcbData > As Long, ByVal dwFlags As Long) As Long > > > > CreateHash =: 3 : 0 > a =. mema 8 > h =. mema 128 > o =. mema 32 > > err=. CryptAcquireContext (<a);' ';' ';PROV_RSA_FULL;CRYPT_VERIFYCONTEXT > err =. CryptCreateHash (<a); ALG_SID_SHA_256 ; 0 ; 0 ; (<<h) > y memw o, 0 , # y > CryptHashData (<h) ; (y) ; (# y) ; 0 > CryptGetHashParam (<h); HP_HASHVAL ; (<o ); (,32) ; 0 > NB. memr o, 0, # y > ) > > > vb code that i adapted this from: > http://khoiriyyah.blogspot.ca/2012/06/vb6-hash-class-md5-sha-1-sha-256-sha.html > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
