Consider the following two ways to generate a SHA512 password hash:
console.log(require("crypto").createHash("sha512").update("mysalt" + "mypassword").digest("base64"));
output:
yarunhSR9I6yzZYCn8KL/WINjXAFzFeS35Z2ykbaO0h8bY7mnkRSYcY+HfJYLA35XtuOSC8lIGOyssUUerTuhw==
openssl passwd -6 -salt mysalt mypassword
output:
$6$mysalt$Ts3752w7WPBw6ENoJhmynzPn47RFb2ze39cgq94y81EGSOvtYpxE6Tatj3ZREJqN5Qn.lBw7wL81kAod63xb5/
The outputs are very different – even if the $6$mysalt$
part from the second output is ignored.
- Is it only a matter of encoding or something more?
- Is it possible to derive one format from the other (by re-encoding etc.)?