I have a linux .so library available that surely works in my linux system. I use the following code examples with the latest PureBasic V4.10 for Linux:
Code: Select all
; #########################################
; Example 1: This works fine (in the first moment)
; #########################################
#CryptLibrary = 0
If OpenLibrary(#CryptLibrary, "libcryptosysapi.so")
; ok
strMessage.s = "Testmessage"
strDigest.s = Space(64)
Ret.l = CallFunction(#CryptLibrary, "SHA2_StringHexHash", @strDigest.s, @strMessage.s)
Debug "Message: " + strMessage.s
Debug "Hash : " + strDigest.s
CloseLibrary(#CryptLibrary)
EndIf
; #########################################
; Example 2: invalid memory access on marked position
; #########################################
; Sub-Procedure
Procedure.s CalcHash(strToHash.s)
strDigest.s = Space(64)
Ret.l = CallFunction(#CryptLibrary, "SHA2_StringHexHash", @strDigest.s, @strToHash.s)
Debug "Message: " + strToHash.s
Debug "Hash : " + strDigest.s
ProcedureReturn strDigest.s ; <<<< INVALID MEMORY ACCESS
EndProcedure
; Main Program
If OpenLibrary(#CryptLibrary, "libcryptosysapi.so")
; ok
Hash.s = CalcHash("Testmessage")
CloseLibrary(#CryptLibrary)
EndIfIs it my misstake or is there a bug in such essential function?
Kukulkan


