Crypt-compatible COS function/implementation - has anyone seen this code?
Hello,
I am looking for ObjectScript implementation of crypt-compatible function, that generates md5 salted hashes (output is in the form of $1$salt$hash). From what I understand it uses its own spin on md5 algorithm:
https://en.wikipedia.org/wiki/Crypt_(C)
http://php.net/manual/en/function.crypt.php
http://www.gnu.org/software/libc/manual/html_node/crypt.html
Does Cache have something like that built in?
Has somebody here seen it implemented somewhere?
Thanks.
Added:
I have found description of the underlying algorithm here: https://www.vidarholen.net/contents/blog/?p=32
Take a look at class %SYSTEM.Encryption, it's all there.
I am trying to generate same output as http://php.net/manual/en/function.crypt.php crypt function (CRYPT_MD5 flavor).
So for example
$salt=crypt("2Ggaobjb","$1$1a2b3c4d$");
returns $1$1a2b3c4d$Y5tt50CQ12xW2saeYnI43, which is not same as pure MD5 hash (like $SYSTEM.Encryption.MD5Hash).
From documentation it seems that crypt creates derived hash based on MD5, but it is not the same.
Thanks, but unfortunately I am unable to find suitable DLL for Win64 with crypt function. I have found 32bit version (GnuWin32/crypt), but it does not work on 64bit environment.
All encryption and hashing are available in %SYSTEM.Encryption class and $zcrc function. Check MD5Hash method. But it doesn't accept salt.
What do you want to do?
Your options are:
Thank you. We are now using Java gateway and we want to replace this with something more native. So it seems that writing own implementation in COS is the only option left. I was hoping that someone has already done that ;)
There is also CNA project - it provides an interface for using native C-compatible shared libraries without anything but Caché ObjectScript code. CNA is a wrapper for libffi. CNA consists of native library (libcna) and Caché class (CNA.CNA). It is a wrapper around $zf functions (you can use them directly too).
Here's the code to call crypt using CNA:
Sample output: