Jason,

Actually, if you need the hash back as text it would be even easier to just 
change the LEP call.

In the first code sample that I posted I used:
"openssl dgst -sha256 -binary"

All you need to do is remove the "-binary" and then change the return type to 
C_TEXT instead of blob.

This should do it all in a single method:

// save this method as: UTIL_hash_sha256_text
If (Count parameters=1)
C_TEXT($0;$result)
C_TEXT($1)
C_TEXT($cmd;$in;$err)
If (Folder separator=":")
  // MacOS
$cmd:="openssl"
Else
  // Windows
$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"
LAUNCH EXTERNAL PROCESS($cmd;$in;$result;$err)
$0:=$result
End if

Then test it like this:
alert(UTIL_hash_sha256_text("test"))

-Tim


Timothy Penner
Technical Services Engineer

4D Inc
95 S. Market Street, Suite #240
CA 95113 San Jose
United States

Téléphone : +1-408-557-4600
Standard :  +1-408-557-4600
Fax :       +1-408-271-5080
Email :     [email protected]
Web :       www.4D.com






**********************************************************************
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]
**********************************************************************

Reply via email to