'springSecurityService.encodePassword for Spring Boot only

I have a legacy app made in grails which uses springSecurityService.encodePassword to generate user password. It's stored in database like this:

{bcrypt}$2a$04$hO0LTu6a54t41bVpxTfPCe0837vYQbA4dZ3HSTlpMEppoB9kmsz0y

On my new app made in Spring Boot only, I'm using BCryptPasswordEncoder().encode(password)

I read that by default grails also uses bcrypt encode. but with spring-boot the password is stored like this:

$2a$10$zHHRMpHWoP6KByWkmgQWqeKN0k.mWE5uD3Fg0Fb92S5eNKaPS5puK

It looks like it's the same encoding but even manually entering the prefix {bcrypt} I can't access the legacy app and also removing it, legacy users can't access the new app.

How can I generate a spring password with the same encoding as springSecurityService.encodePassword?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source