1

It seems the ENCRYPT function works very differently on Linux from on macOS. I wonder why?

set @salt := SHA2(RAND(), 512);
select ENCRYPT('abc', CONCAT('\$6\$rounds=5000$', @salt));

Linux 5.4.174-2-pve / Mariadb 10.7

$6$rounds=5000$36fcf04d0f759de9$eZedOjHbDve6bomhxF95pzFUajCzFGgnNxh8JapGZlCb5NzzT2ze96hhO8s803zpPGMP4L48hhBm.6cHAv6Op/

macOS 12.4 / Mariadb 10.8

$6G/aJp5H5PCs
Progman
  • 16,827
  • 6
  • 33
  • 48
  • I assume you're commenting on the length, not the fact the results are different (which is expected since you're using a random salt). What happens if you use the same salt? Is the macOS version a substring of the Linux version. Ages ago, I ran into an issue where the `crypt` command that shipped with Solaris was very different from GNU crypt, potentially due to export restrictions. – Barry Carter Jul 24 '22 at 11:16
  • 1
    Does this answer your question? [How to get same crypt(3) function in Mac OS X as Linux gcc/gnu crypt(3)? Linux gcc crypt(3) has MD5 and SHA512. Apple Gcc crypt(3) \*only\* uses DES](https://stackoverflow.com/questions/32569597/how-to-get-same-crypt3-function-in-mac-os-x-as-linux-gcc-gnu-crypt3-linux-g) (to make it a real dupe: `ENCRYPT` uses `crypt` syscall) – STerliakov Jul 24 '22 at 11:16

1 Answers1

2

MariaDB's ENCRYPT() function uses the crypt() function of the libcrypt library. The implementation of crypt() is different on Mac and Linux: While Linux uses SHA512, the Mac variant uses DES.

Georg Richter
  • 5,970
  • 2
  • 9
  • 15