Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generate SHA1 in VFP
Message
From
07/11/2023 00:34:20
 
 
To
06/11/2023 18:44:31
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
01687209
Message ID:
01687211
Views:
49
>Is there a way to generate SHA1 in VFP?
>
>Right now I'm using MySQL to generate SHA1
>
>
>STORE calcSqlConnect() TO dlnConnHandle
>TEXT TO dlcSQL TEXTMERGE noshow
>select sha1('abcde')
>ENDTEXT 
>STORE SQLEXEC(dlnConnHandle, dlcSql, 'dummy') TO dlnSql
>
>
>But then I don't know how to take out the return value
>
>Thanks for the help
>
>Jerry

https://web.archive.org/web/20161112114026/http://sweetpotatosoftware.com/blog/index.php/2005/08/30/visual-foxpro-and-hash-functions
https://github.com/VFPX/Win32API/blob/master/samples/sample_483.md
DECLARE A_SHAInit IN advapi32.dll String @
DECLARE A_SHAUpdate IN advapi32.dll String @, String @, Integer
DECLARE A_SHAFinal IN advapi32.dll String @, String @

m.sha_ctx = REPLICATE(CHR(0),168)
m.sha_dig = REPLICATE(CHR(0),20)

m.str = "Your string"
A_SHAInit(@m.sha_ctx)
A_SHAUpdate(@m.sha_ctx, @m.str, LEN(m.str))
A_SHAFinal(@m.sha_ctx, @m.sha_dig)

result = ""
FOR i = 1 TO 20
 result = result + LOWER(RIGHT(TRANSFORM(ASC(SUBSTR(m.sha_dig, i, 1)), "@0"),2))
NEXT
Wait Window result
Previous
Reply
Map
View

Click here to load this message in the networking platform