For automating the creation of virtual machines, I generate the passwords for /etc/shadow from some Ruby code. This is done on the host. The host can be Linux or Windows.
On a linux host
"mypassword".crypt("$6$" + "123SaLt9")
returns
$6$123SaLt9$idgUFrrwVkpDMcoHj7SAYH0UwCY6LymbsR9yTDrelYgcZ2wstoynmLIY83qBF0/BIT4Od.rQL2g3n2jEG/VXp/
which is correct and works for /etc/shadow.
However, on some Windows 10 hosts (since about two weeks ago on the machines of two colleagues) the same line of code returns
$6MrNddDu3Hf6
which, obviously, cannot work. (similar behaviour was observed for MacOS here https://judepereira.com/blog/use-ruby-to-generate-your-shadow-password/)
I overlooked that this function is platform dependent (https://apidock.com/ruby/String/crypt). Besides the fact that it did work a couple of weeks ago, I assume that I cannot take for granted that it works reliably on Windows 10 hosts.
What I need is a solution that returns the proper password hash in MFC format on Linux and Windows 10 hosts. As I understand, the password part of the MFC is not just a base64 encoded result of generating a SHA512 but rather a much more complicated process (https://akkadia.org/drepper/SHA-crypt.txt, Using ruby to generate SHA512 crypt-style hashes formatted for /etc/shadow?). I want to avoid to essentially implement the algorithm myself in Ruby. I did a couple of hours of research but couldn't find anything useful so far.
Any ideas how to avoid this problem on Windows, i.e. how to generate these password hashes platform-independently?