0

What I need is to get the same result as:

# openssl passwd -1 -salt SaltSalt thesecretpassword
$1$SaltSalt$d4KyTrYpU26ghRyvibVDY0

At least the last part(d4KyTrYpU26ghRyvibVDY0), as the first two parts are fixed to $1$SaltSalt$.

This is needed, so it can be set for a password of a Linux user.

ILAPE
  • 47
  • 1
  • 5
  • You should ask a specific question for a particular problem. Since Stack Overflow hides the Close reason from you: *"Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it."* You might want to [Take the Tour](https://stackoverflow.com/tour). In the meantime, maybe [Rent A Coder](http://www.rentacoder.com) or [Freelancer](http://www.freelancer.com) can help you out. – jww Jul 20 '17 at 15:53
  • @jww This seems like a perfectly valid question to me. It is clear what the problem is and it is not immediately obvious that `$1$` needs to be appended to the salt to make a function like `Crypt.crypt` give the expected output. Which library is used is in this case, only a circumstantial part of the solution. – Jodiug Jul 15 '20 at 13:33

1 Answers1

1

I found it in commons-codec:

Crypt.crypt(password, String.format("$1$SaltSalt", "thesecretpassword"))

ILAPE
  • 47
  • 1
  • 5