My goal
=======

I have an old MySQL database with usernames and passwords hashed using sha256. I don't have the original passwords and it is not possible to learn them. This is a simple user migration from a database to a Linux system. I need to create all those users on linux, because that linux authentication will be used in other part, and we don't want to make users create credentials again.

My thoughts so far
==================

I have seen that you can use crypt to generate that strange base64 format that uses the shadow file, but that requires the original password. I understand the process is like this in Linux:

1. Generate a simple sha512 hash based on the salt and password
2. Loop 1000 5000 times, calculating a new sha512 hash based on the previous hash concatenated with alternatingly the hash of the password and the salt. Additionally, sha512-crypt allows you to specify a custom number of rounds, from 1000 to 999999999
3. Use a special base64 encoding on the final hash to create the password hash string.

Ref: <https://www.vidarholen.net/contents/blog/?p=33>

Since the first step is generating the hash with the salt, I think it should be possible. Since linux is open source I believe I could try to get the source code of crypt somewhere like this <https://code.woboq.org/userspace/glibc/crypt/crypt-entry.c.html>
and start in step 2, but before doing all that I don't know if it will work out, I was wondering if there is an easier way. If there is not, where could I get the correct source code of linux for doing that? I am not sure if the link I provided is correct.

Thanks a lot.