You need to distinguish between SHA512 (a general-purpose hash function) and sha512crypt (a password hashing function based on SHA512). A string starting with $6$
is the output from sha512crypt. It's possible you knew this already, but the wording of your question leaves open the possibility that you didn't.
The specification for sha512crypt is here. It doesn't say much about the construction of the salt, only this:
For the SHA-based methods the SALT string can be a simple string of
which up to 16 characters are used.
At least one implementation (for python) says that the salt must be composed of alphanumerics, dot, and slash (the characters used in the original DES-based unix crypt). I think it would be wise to stick to those characters.
The hashed-secret
is base64 encoded, not with the MIME base64 alphabet but with the unix crypt alphabet.
The encoding used is as follows:
111111111122222222223333333333444444444455555555556666
0123456789012345678901234567890123456789012345678901234567890123
----------------------------------------------------------------
./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz