For a recent tech note I just published I needed to do SHA256 hashing so I used
a Launch External Process call to OpenSSL like this:
If (Count parameters=1)
C_BLOB($0;$result)
C_TEXT($1)
C_TEXT($cmd;$in;$err)
If (Folder separator=":")
// MacOS has openssl installed at the system level
$cmd:="openssl"
Else
// Windows uses openssl from the database resources folder
$cmd:=Get 4D folder(Current resources folder)+"openssl"+Folder
separator+"win64"+Folder separator+"openssl.exe"
End if
C_TEXT($true_t)
$true_t:="true"
SET ENVIRONMENT VARIABLE("_4D_OPTION_CURRENT_DIRECTORY";Temporary folder)
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";$true_t)
$in:=$1
$cmd:=$cmd+" dgst -sha256 -binary"
LAUNCH EXTERNAL PROCESS($cmd;$in;$result;$err)
$0:=$result
End if
On Mac it just works but on Windows you need to place the OpenSSL binary files
in the database resource folder, I used this path:
// $cmd:=Get 4D folder(Current resources folder)+"openssl\win64\openssl.exe"
Hope this helps!
-Tim
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************