1

How do you generate a salted hash for users in spring security 3x from a bash command line?

Nigel_V_Thomas
  • 907
  • 13
  • 27

2 Answers2

1

Spring security merges the password and salt in the format password{salt} instead of a simple concatenation of password+salt, from the terminal enter:

echo -n password{salt} | shasum -a 1

Please note: Spring security recommends using the encode method on PasswordEncoder

If you want to generate encoded passwords directly in Java for storage in your user database, then you can use the encode method on the PasswordEncoder

Source : Hashing and Authentication

Nigel_V_Thomas
  • 907
  • 13
  • 27
1

The Spring Boot CLI provides a command for that. The Spring Security Reference recomends its use.

spring encodepassword password
Jefferson Lima
  • 5,186
  • 2
  • 28
  • 28